note 17870 added to function.call-user-method
| From: | php-general at lists dot php dot net | Date: | Sun, 30 Dec 2001 06:17:40 +0000 |
| Subject: | note 17870 added to function.call-user-method | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-23958@lists.php.net to get a copy of this message | ||
Instead of using this function, I would recommend running methods via the eval():
class my_class {
...
function anymethod() {
...
}
}
$my_object = new my_class();
$my_method = 'anymethod()';
$str_object = '$my_object'; /* notice how it is a string of the object */
eval($tr_object.'->'.$my_method);
The reason I like this method more than the call_user_method() function is that call_user_method()
has trouble when you have classes embedded in classes, like:
$class = new classname();
$class->any_variable = new class2name();
Running methods that are in the class object "$class->any_variable" do not seem to
work.
--
http://www.php.net/manual/en/function.call-user-method.php
http://master.php.net/manage/user-notes.php?action=edit+17870
http://master.php.net/manage/user-notes.php?action=delete+17870
http://master.php.net/manage/user-notes.php?action=reject+17870