note 55164 deleted from function.call-user-func by cmb
| From: | cmb@php.net | Date: | Sun, 08 Dec 2019 11:13:03 +0000 |
| Subject: | note 55164 deleted from function.call-user-func by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213445@lists.php.net to get a copy of this message | ||
Note Submitter: mw at lanfear dot com
----
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 ...]