17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 720 Views |
-
Getting static vars

12 December 2008 at 4:00am
What's the best way to get the value of a static var on an unknown class? Silverstripe uses a pretty clever (albeit ugly) technique that looks something like:
$var = eval("return $className::\$my_var;");
But then in other places i see:
$var = $this->stat('my_var');
And still in other places, I see:
$class = new ReflectionClass('my_class');
$var = $class->getProperty('my_var');Which is the preferred method? Are a lot of these legacy techniques to support older PHP versions? Seems like it should be the same every time.
| 720 Views | ||
|
Page:
1
|
Go to Top |
