我想在调用之前检查$this->_controller
函数foo
是否存在。
通话示例:
call_user_func_array([$this->_controller, $this->_url[1]]);
这将调用插入URL中的控制器中的函数url[1]
,基本上是:
webserver/backend/foo
我想检查foo是否确实存在于后端。
我该怎么做?
答案 0 :(得分:1)
大多数事情都有功能。检查method_exists()
:
if(method_exists($this->_controller, $this->_url[1])) {
call_user_func_array([$this->_controller, $this->_url[1]]);
}
其他用途请参阅is_callable()
。