note 84647 rejected from function.call-user-func-array by danbrown
| From: | danbrown@php.net | Date: | Wed, 23 Jul 2008 15:25:07 +0000 |
| Subject: | note 84647 rejected from function.call-user-func-array by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142612@lists.php.net to get a copy of this message | ||
Note Submitter: yannick at myconcept dot be
----
I use the magic autoload function to load my classes and put an error handler on my autoload to log
load errors... I've got some weird traces : unknown load attempts due to the combination of
call_user_func_array & __autoload... PHP try to load 5 or 6 times the autoload class with very
strange class names... A call_user_func_array will call 5 times autoload before
'triggering' a warning... I someone knows how to avoid those attempts...
Ex :
"
class xbbe9xrngdvxqh{
public function MyMethod(){
echo 'Hello world !';
}
}
class MyWorkingClass {
//Error will call xbbe9xrngdvxqh
}
function __autoload($class){
echo 'Loading class '.$class.'<br>';
}
call_user_func_array(array('MyClass','MyMethod'),false);
call_user_func_array(array('WS_Auth','MyMethod'),false);
call_user_func_array(array('MyTestClass','MyMethod'),false);
call_user_func_array(array('MyWorkingClass','MyMethod'),false);
"
Will return :
Loading class MyClass
Loading class 3ziu1ci
Loading class MyClass
Loading class 3ziu1ci
Loading class MyClass
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a
valid callback, 'MyClass::MyMethod' was given in \Yannick\Projets\bug_php_autoload.php on
line 13
Loading class WS_Auth
Loading class 5e95664
Loading class WS_Auth
Loading class 5e95664
Loading class WS_Auth
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a
valid callback, 'WS_Auth::MyMethod' was given in \Yannick\Projets\bug_php_autoload.php on
line 14
Loading class MyTestClass
Loading class wepkt0wxpp9
Loading class MyTestClass
Loading class wepkt0wxpp9
Loading class MyTestClass
Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected
to be a valid callback, 'MyTestClass::MyMethod' was given in
Yannick\Projets\bug_php_autoload.php on line 15
Hello world !