Re: Getting static member for a class which name is stored

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jake Press wrote:
Simas Toleikis wrote:

Jake Press wrote:

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.


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! :)

How about:

<?php
class Myclass
{
    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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux