I'm getting the old familiar "Fatal error: Using $this when not in object context" referring to $this->test = 'test';
in the following class:
class Example {
public $test;
public function index() {
$this->test = 'test';
}
}
The class method is called via call_user_func_array(array('example', 'index'), $params);
. I can only assume that call_user_func_array
has for some reason decid开发者_运维百科ed to call the index method as static e.g. example::index()
? However I haven't figured out a fix for this and oddly I've not had a problem with it until recently.
This works:
$obj = new Example();
call_user_func_array(array($obj, 'index'), $params);
Your code basically does:
Example::index($params);
which calls index
statically, which you correctly assumed.
精彩评论