|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-03-01 17:03 UTC] ajrattink at correct dot net
Description: ------------ --- From manual page: http://www.php.net/function.call-user-func#Parameters --- The manual states that call_user_func(array($classname, $methname), ...) will call the static method of the class indicated by +classname+ but fails to mention that it does not work if the class is imported in a namespace. To avoid disappointed programmers, I think it should. Example: use X as Y; call_user_func(array('Y', 'f'), ...) will not work. This means that if the original class caused a nameconflict there is absolutely no way of calling it. Ever. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 23 08:00:02 2025 UTC |
Hi, I can confirm that call_user_func does not seem to mind namespaces: ---- namespace A; class X { public static function f () { echo 'c'; } } X::f(); call_user_func(array('X', 'f')); ----- Expected: cc ----- Actual: c Warning: call_user_func() expects parameter 1 to be a valid callback, class 'X' not found in .... ----- One comment to the last sentence of the original commenter: there is a way: just use the fully qualified name, in my example call_user_func(array('\A\X', 'f')); will work as expected.