当php 在子类中调用父类的方法,如果这个父类中的方法里调用了其他的方法,而这个方面在当前父类与子类中都有的话,那么是先调用子类的。
class A extends B{
public function route()
{
parent::route();
$Itemid = JRequest::getInt('Itemid');
$this->authorise($Itemid);
}
public function test(){
echo "hello";
}
}
class B{
public function route()
{
$this->test(); //注意此处调用的是A类中的test()方法,这是我在看joomla代码中总结的经验
}
public function test(){
echo "hello";
}
}