Reputation: 67710
Is there such a thing?
Some kind of a magic function that allows you to change stuff before the undefined function call error gets thrown?
Like __call
, but for normal functions :)
Upvotes: 4
Views: 818
Reputation: 17762
I would do the cheking BEFORE calling the method like this:
$obj = new Foo();
$method = "myMethod";
if(is_callable(array($obj, $method)){
$obj->$method();
}else{
// Do some stuff
}
Upvotes: 2