![](/img/trans.png)
[英]In Java, can you call a parent class's superclass constructor through the constructor of the child class of the parent class?
[英]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類構造函數嗎?
不,您需要在子類中調用父構造函數。
public function __construct() {
parent::__construct();
//...other code
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.