是不是代碼執(zhí)行完成后,對象會被自動銷毀,不需要手動銷毀。
<?php
class Car {
??? //增加構造函數(shù)與析構函數(shù)
??? function __construct() {
??????? print "構造函數(shù)被調(diào)用 \n";
??? }
?? ?
??? function __destruct() {
??????? print "析構函數(shù)被調(diào)用 \n";
??? }
}
$car = new Car();
2019-07-01
我覺得是的。
當PHP代碼執(zhí)行完畢以后,會自動回收與銷毀對象,因此一般情況下不需要顯式的去銷毀對象。
2019-05-09
銷毀時 才調(diào)用析構函數(shù)