php继承中this调用方法的顺序
时间:2020-12-28 11:40:40
收藏:0
阅读:0
class father
{ //定义father类
public function getMethod()
{ //定义方法
$this->method();
}
public function method()
{ //定义方法
echo ‘<br />father method‘;
}
}
class son extends father
{ //定义继承自father类的son类
public function method()
{ //重写父类方法
echo ‘son method‘;
}
}
$son = new son(); //实例化son类的对象
//调用son类的方法
$son->getMethod();
输出:son method
评论(0)