[英]PHP -If we create object of child class in php, does it call parent class constructor and then child class constructor like java?
PHP-如果我们在php中创建子类的对象,它会调用父类构造函数,然后调用像Java这样的clild类构造函数吗?
No, you need to call the parent constructor in child class. 不,您需要在子类中调用父构造函数。
public function __construct() {
parent::__construct();
//...other code
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.