The code snippet below shows an interesting technique to daisy chain calls to a particular method without having to implicitly call the parent::method() in the child method. It takes advantage of php's __call and self
<?php
class b extends a
{
public function _init()
{
echo 'hello from b::_init<br>';
}
}
class a
{
public function _init()
{
echo 'hello from a::_init<br';
}
public function __call($n, $a)
{
echo 'hello from a::__call<br>';
call_user_func_array(array($this, '_'.$n), $a);
call_user_func_array(array(self, '_'.$n), $a);
}
}
$obj = new b;
$obj->init();
?>
Related posts:
WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.