- is_callable: documentation ( source)
<?php
class A
{
private $log;
function __construct() {
$this->log = function () { echo 'log'; };
}
private function privateMethod() {
echo 'calling private method';
}
public function __call($method, $args) {
if (is_callable(array($this, $method))) {
return call_user_func_array($this->$method, $args);
}
}
}
$a = new A();
$a->log();
$a->privateMethod();