<?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();
?>
__construct() 和 __destruct() 前面是两个下划线;