note 99870 added to function.call-user-func
| From: | gskluzacek dot nospam at gmail dot com | Date: | Sat, 11 Sep 2010 17:38:52 +0000 |
| Subject: | note 99870 added to function.call-user-func | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-172485@lists.php.net to get a copy of this message | ||
if you simply want to dynamically call a method on an object it is not necessary to use
call_user_function but instead you can do the following:
<?php
$method_name = "AMethodName";
$obj = new ClassName();
$obj->{$method_name}();
?>
I've used the above so I know it works.
Regards,
-- Greg
----
Server IP: 69.147.83.197
Probable Submitter: 129.188.33.26
----
Manual Page -- http://www.php.net/manual/en/function.call-user-func.php
Edit -- https://master.php.net/note/edit/99870
Del: integrated -- https://master.php.net/note/delete/99870/integrated
Del: useless -- https://master.php.net/note/delete/99870/useless
Del: bad code -- https://master.php.net/note/delete/99870/bad+code
Del: spam -- https://master.php.net/note/delete/99870/spam
Del: non-english -- https://master.php.net/note/delete/99870/non-english
Del: in docs -- https://master.php.net/note/delete/99870/in+docs
Del: other reasons-- https://master.php.net/note/delete/99870
Reject -- https://master.php.net/note/reject/99870
Search -- https://master.php.net/manage/user-notes.php