Re: Getting static member for a class which name is stored
| From: | Greg Beaver | Date: | Sun, 28 Nov 2004 21:03:28 +0000 |
| Subject: | Re: Getting static member for a class which name is stored | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-203027@lists.php.net to get a copy of this message | ||
Jake Press wrote:
Simas Toleikis wrote:How about: <?php class Myclass {Jake Press wrote:Morning, Umm, it is an unclear syntax limitation, which is a bug. ... either language or manual. i understand what you are saying, i beleive i disclaimer'd my own examples somewhere down the line in those threads ;) i beleive there should be a better way to do this without: - using reflection - instantiating the class and using a method to retrieve the variable - eval Also please notice the existance of the "call_user_func" and what this gives us ;) = this gives us a solution (workaround??) to access static functions within a class Perhaps we need a similar function to provide access to our static variables! :)Hi Francisco, Your not alone, a number of other users have enountered this bug.string get_class ( object obj ) Its not a bug... You are getting class name as a string for output purposes etc.. Doing something like "TestClass"::some_static is ofcourse illegal wih strings.
public static $myvar = "easy enough";} echo Myclass::$myvar; ?> The only problem is if you want to be able to generically access a static variable from any class that has it, like $Myclass::$myvar. Greg