note 88110 added to function.call-user-func
| From: | kucerar at hhmi dot org | Date: | Sun, 11 Jan 2009 05:43:35 +0000 |
| Subject: | note 88110 added to function.call-user-func | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-149046@lists.php.net to get a copy of this message | ||
Julian said:
...
You don't need to use this function to call a variable class function. Instead you can do the
following:
$this->{$fnname}();
The example works in PHP 5 from within the class. It is the {} that do the trick.
...
I didn't believe it but it really worked. Just that.
Furthermore outside of the class this also works:
$obj->{$fnname}();
This is very nice to have.
Rich
----
Server IP: 64.71.164.2
Probable Submitter: 206.241.2.38
----
Manual Page -- http://www.php.net/manual/en/function.call-user-func.php
Edit -- https://master.php.net/note/edit/88110
Del: integrated -- https://master.php.net/note/delete/88110/integrated
Del: useless -- https://master.php.net/note/delete/88110/useless
Del: bad code -- https://master.php.net/note/delete/88110/bad+code
Del: spam -- https://master.php.net/note/delete/88110/spam
Del: non-english -- https://master.php.net/note/delete/88110/non-english
Del: in docs -- https://master.php.net/note/delete/88110/in+docs
Del: other reasons-- https://master.php.net/note/delete/88110
Reject -- https://master.php.net/note/reject/88110
Search -- https://master.php.net/manage/user-notes.php