1被销毁... 2被销毁... 3被销毁...
—————脚本结束——————

<?php
header
('Content-Type: text/html; charset=utf-8');
class 
test{
    public 
$i;
function 
__construct($i) {$this->$i; }
function 
__destruct() { echo $this->i."被销毁...\n"; }
}
// 直接new对象会被销毁;
new test('1');
$a = new test('2');
// 给一个对象变量重新赋值之前的对象会被销毁。
$a 1;
// 正常的实例对象会在脚本运行结束自动销毁
$a=new test('3');
//使用unset也可以手动删除对象从而触发
unset($a);
$a=new test('4');
echo 
"<br/>—————脚本结束——————<br/>"
highlight_file(__FILE__);
?>
4被销毁...