【发布时间】:2013-11-05 20:58:18
【问题描述】:
我有这个超类:
Class BaseController{
public function __construct(){
$this->view = new BaseView();
}
}
我有 3 个扩展它的类。如何运行基类的构造函数,而不必将parent::__construct(); 放入子类的每个构造函数中?
【问题讨论】:
-
你不能......一个子类方法覆盖父类的方法,除非你明确地调用它......或者不为你的子类定义一个 __construct() 方法
标签: php inheritance constructor