php继承中this调用方法的顺序
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
- 上一篇 »Java面向对象之继承、构造方法、重写、重载
- 下一篇 »Java继承 练习题