如果我们写两个类,如下:
class Action{
public function __construct()
{
echo 'hello Action';
}
}
class IndexAction extends Action{
public function __construct()
{
echo 'hello IndexAction';
}
}
$test = new IndexAction;
//output --- hello IndexAction
class IndexAction extends Action{
public function __initialize()
{
echo 'hello IndexAction';
}
}
class IndexAction extends Action{
public function __construct()
{
parent::__construct();
echo 'hello IndexAction';
}
}
class Action{
public function __construct()
{
if(method_exists($this,'hello'))
{
$this -> hello();
}
echo 'hello Action';
}
}
class IndexAction extends Action{
public function hello()
{
echo 'hello IndexAction';
}
}