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