我已经解决了这个问题,我只需要知道该怎么做.我得到上面的错误,因为我刚刚意识到该类正在运行为class :: function($ values)而不是class-> function($ values).
有谁知道如何转换此函数来实例化该类然后运行具有值的函数?
private function _load($values=null) {
define('LOADED_CONTROLLER', $this->controller);
define('LOADED_FUNCTION', $this->function);
$function = $this->function;
$controller = new $this->controller;
($values == null) ? $controller->$function() : call_user_func_array(array($this->controller, $function), $values);
}
Run Code Online (Sandbox Code Playgroud)
您已经实例化了该类:
$controller = new $this->controller;
Run Code Online (Sandbox Code Playgroud)
只需使用你$controller的call_user_func_array:
($values == null) ? $controller->$function() : call_user_func_array(array($controller, $function), $values);
Run Code Online (Sandbox Code Playgroud)
在您的代码中,您尝试在类上调用静态方法if $value != null.如果您$this在此方法中使用,那当然会导致错误.
| 归档时间: |
|
| 查看次数: |
1781 次 |
| 最近记录: |