- method_exists: documentation ( source)
<?php
class ParentClass{
protected function run(){}
public function __call($method,$arguments) {
echo "<br/>######Call ". get_called_class()."########<br>";
if(method_exists($this, $method)) {
call_user_func_array(array($this,$method),$arguments);
}
}
}
class first_child extends ParentClass{
protected function run(){
echo "<br>running " . get_called_class();
$x= new second_child;
$x->run();
}
}
class second_child extends ParentClass{
protected function run(){
echo "<br>running " . get_called_class();
}
}
$y= new first_child;
$y->run();