|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-09-08 04:53 UTC] curt@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 21:00:01 2025 UTC |
Description: ------------ If you use call_user_func(array("parent", "somefunc")), an error is triggered: call_user_func(parent::x) [function.call-user-func.html]: First argument is expected to be a valid callback However, doing this with 'self' instead of 'parent' works fine, and behaves as expected. This may be a recurrence of Bug #26543, in which neither 'parent' nor 'self' could be used in call_user_func, so you might want to take a look at that. Reproduce code: --------------- <?php class P { function __construct() { $args = func_get_args(); print_r($args); } } class D { function __construct() { $args = func_get_args(); call_user_func_array(array("parent", "__construct")); } } class C { function __construct() { $args = func_get_args(); call_user_func_array(array("self", "func"), $args); } function func() { $args = func_get_args(); print_r($args); } } $c = new C(1,2,3,4); // behaves as expected $d = new D(1,2,3,4); // doesn't behave as expected ?> Expected result: ---------------- Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 ) Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 ) Actual result: -------------- Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 ) Warning: call_user_func(parent::x) [function.call-user-func.html]: First argument is expected to be a valid callback in c:\Inetpub\wwwroot\test.php5 on line 3