note 57433 added to language.oop
| From: | dave at davidhbrown dot us | Date: | Tue, 04 Oct 2005 04:10:01 +0000 |
| Subject: | note 57433 added to language.oop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-96328@lists.php.net to get a copy of this message | ||
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.
----
Manual Page -- http://www.php.net/manual/en/language.oop.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+57433
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57433&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57433&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57433&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57433&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57433&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57433&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57433&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+57433&report=yes
Search -- http://master.php.net/manage/user-notes.php