我要完成以下,但我不知道如何做到这一点:PHP类的继承和扩展方法
class foo {
function doSomething(){
// do something
}
}
class bar extends foo {
function doSomething(){
// do something AND DO SOMETHING ELSE, but just for class bar objects
}
}
是否有可能做到这一点,同时仍然使用doSomething()
方法,还是我必须创建一个新的方法?
编辑:为了澄清,我不想在继承的方法中重申'做些什么',我只想在foo-> doSomething()方法中声明一次,然后在子类中构建它。
这正是我所需要的;谢谢! – Matthew 2012-01-27 21:51:41