php __destruct没执行,什么时候__destruct不会在PHP中调用?

class MyDestructableClass {

function __construct() {

print "\nIn constructor\n";

$this->name = "MyDestructableClass";

}

function __destruct() {

print "\nDestroying " . $this->name . "\n";

}

}

$obj = new MyDestructableClass();

当上面的脚本在一个复杂的环境中,__destruct将不会被调用退出时,但我不能重现它easy.Have有人注意到了这一点?

编辑

我将在这里发布整个东西,它是symfony的测试环境,这意味着如果你熟悉框架,你可以很容易地再现它:

require_once dirname(__FILE__).'/../bootstrap/Doctrine.php';

$profiler = new Doctrine_Connection_Profiler();

$conn = Doctrine_Manager::connection();

$conn->setListener($profiler);

$t = new lime_test(0, new lime_output_color());

class MyDestructableClass {

function __construct() {

print "\nIn constructor\n";

$this->name = "MyDestructableClass";

}

function __destruct() {

print "\nDestroying " . $this->name . "\n";

}

}

$obj = new MyDestructableClass();

$news = new News();

$news->setUrl('http://test');

$news->setHash('http://test');

$news->setTitle('http://test');

$news->setSummarize('http://test');

$news->setAccountId(1);

$news->setCategoryId(1);

$news->setThumbnail('http://test');

$news->setCreatedAt(date('Y-m-d H:i:s',time()));

$news->setUpdatedAt(date('Y-m-d H:i:s',time()));

$news->save();

exit();

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值