note 55163 added to function.call-user-func
| From: | php-general at lists dot php dot net | Date: | Tue, 26 Jul 2005 20:48:58 +0000 |
| Subject: | note 55163 added to function.call-user-func | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-92510@lists.php.net to get a copy of this message | ||
This function is actually quite useful for calling static methods on classes, which you CANNOT call
as:
$v1 = 'MyClass';
$m1 = 'method';
$v1::$m1(); // syntax error -- not permitted.
The following, however, DOES work quite well, and is hopefully slightly faster than eval() ...
$ar = array($v1, $m1);
call_user_func($ar); // works teh awes0me!!1!
[I am, however, presuming PHP5 here ...]
----
Manual Page -- http://www.php.net/manual/en/function.call-user-func.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55163
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55163&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55163&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55163&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55163&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55163&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55163&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55163&report=yes
Search -- http://master.php.net/manage/user-notes.php