note 57433 deleted from language.oop by danbrown
| From: | danbrown@php.net | Date: | Sat, 07 Nov 2009 19:03:22 +0000 |
| Subject: | note 57433 deleted from language.oop by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-162560@lists.php.net to get a copy of this message | ||
Note Submitter: dave at davidhbrown dot us
----
It appears that one must use eval if calling a static function where the name of the class is in a
variable:
echo $class::staticfunc();
gets you a "parse error, unexpected T_PAAMAYIM_NEKUDOTAYIM" (in PHP 4.4.0)
while
echo eval("return $class::staticfunc();");
behaves as desired.
Contrast this limitation with
->which will accept a variable on both sides -- e.g.,
$myClass->$myFunc() -- and, of course, new $myClass is perfectly happy. The expression
myClass::$myFunc() also works.