class Parent_class{
function parent_says(){
echo "HI. I'm parent!";
}
}
class Child_class extends Parent_class{
function parent_says(){
//I want it to also says "HI. I'm parent!", that's inside parent method.
echo "I say hello!";
}
}
$Child_class = new Child_class;
$Child_class->parent_says();
答案 0 :(得分:3)
首先使用parent::
调用父类的方法。 E.g。
class Child_class extends Parent_class{
function parent_says(){
parent::parent_says();
echo "I say hello!";
}
}
有关详细信息,请参阅here。