- is_callable: documentation ( source)
<?php
class Foo{
public function __call($method, $args) {
if(is_callable(array($this, $method))) {
return call_user_func_array($this->$method, $args);
}
// else throw exception
}
}
$c = function($who) { return "Hello $who"; };
echo $c->call(new Foo,'Wide World');