為什么我這個代碼輸出不了,有沒有大佬教教
<?php
class Car {
? ? function _construct() {
? ? ? ? print "構造函數被調用 \n";
? ? }
? ? function _destruct() {
? ? ? ? print "析構函數被調用 \n";
? ? }
}
$car = new Car();
?>
<?php
class Car {
? ? function _construct() {
? ? ? ? print "構造函數被調用 \n";
? ? }
? ? function _destruct() {
? ? ? ? print "析構函數被調用 \n";
? ? }
}
$car = new Car();
?>
2021-08-09
舉報
2021-08-10
<?php
class Car {
? ? function __construct() {
? ? ? ? print "構造函數被調用 \n";
? ? }
? ? function __destruct() {
? ? ? ? print "析構函數被調用 \n";
? ? }
}
$car = new Car();
?>
__construct() 和 __destruct() 前面是兩個下劃線;