關(guān)于析構(gòu)函數(shù)的父子關(guān)系怎么確定?
<?php
//關(guān)于類的構(gòu)造函數(shù)和析構(gòu)函數(shù)(父子類)
class Car{
//定義一個構(gòu)造函數(shù)
function __construct(){
print "父類構(gòu)造函數(shù)被調(diào)用啦~ \n";
}
}
class Car2 extends Car{
function __construct(){
print "子類構(gòu)造函數(shù)被調(diào)用啦~";
// parent::__construct();
}
function __deconstruct(){
print "子類析構(gòu)函數(shù)也被調(diào)用啦!";
}
}
$car = new Car2;
unset($car);
?>
上面是代碼,既然構(gòu)造函數(shù)有父子關(guān)系,那么我試了一下看看析構(gòu)函數(shù)的父子關(guān)系是怎樣的。 結(jié)果析構(gòu)函數(shù)都不輸出。。。。 求賜教!
2019-01-25
你的析構(gòu)函數(shù)名寫錯了,析構(gòu)函數(shù)是__destruct