note 36168 added to function.call-user-func

From: Date: Mon, 29 Sep 2003 12:49:32 +0000
Subject: note 36168 added to function.call-user-func
Groups: php.notes 
Request: Send a blank email to php-notes+get-57272@lists.php.net to get a copy of this message
With overload()ed classes call_user_func_* calls real class methods only. If the method does not exist then PHP does not try with the "__call()" magic method (at least until PHP 4.3.3). See this: <?php class A { function A() {} function __call($method, $args, &$ret) { echo "__call(): You called '{$method}()'<br>\n"; return true; } function regular() { echo "You called 'regular()'<br>\n"; } }; overload("A"); $a = new A; $a->regular(); // Works, calls regular() call_user_func(array(&$a, "regular")); // Works, calls regular() $a->hello(); // Works, calls __call() call_user_func(array(&$a, "hello")); // Does NOT work! ?> ---- Manual Page -- http://www.php.net/manual/en/function.call-user-func.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+36168 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+36168&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+36168&report=yes

« previous php.notes (#57272) next »