如何防止在foo类中创建以下something
方法?如何不允许在PHP中定义子类方法
class fooBase{
public function something(){
}
}
class foo extends fooBase{
public function __construct(){
echo $this->something(); // <- should be the parent class method
}
public function something(){
// this method should not be allowed to be created
}
}
可以'__construct'方法是最终的太(如果fooBase有一个)? – Alex 2011-06-06 08:18:19
是的,__construct可以是最终的。如果你说在父母课堂上是最终的,你就不能在孩子身上有一个。 – SamT 2011-06-06 08:26:33
事实上,正如SamT所说,你可以最终做出__construct。 – MGwynne 2011-06-06 08:37:10