我本以为很多人会想知道这是否可能,但我找不到任何重复的问题......请纠正我。
我只是想知道PHP是否提供纯虚函数。我想要以下
class Parent {
// no implementation given
public function foo() {
// nothing
}
}
class Child extends Parent {
public function foo() {
// implementation of foo goes here
}
}
非常感谢。
您可以创建抽象函数,但也需要将父类声明为抽象函数:
abstract class Parent {
// no implementation given
abstract public function foo();
}
class Child extends Parent {
public function foo() {
// implementation of foo goes here
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)