Reputation: 780
I would like to check if the $this->_controller
function foo
exist before I call it.
Example of call:
call_user_func_array([$this->_controller, $this->_url[1]]);
This will call the function url[1]
in the controller inserted in the URL so, basically:
webserver/backend/foo
I want check if foo actually exists in the back-end.
How can I do this?
Upvotes: 2
Views: 592
Reputation: 78994
There are functions for most things. Check method_exists()
:
if(method_exists($this->_controller, $this->_url[1])) {
call_user_func_array([$this->_controller, $this->_url[1]]);
}
For other uses see is_callable()
.
Upvotes: 1