我可以信任调用PHP __destruct()方法吗? [英] Can I trust PHP __destruct() method to be called?

查看:101
本文介绍了我可以信任调用PHP __destruct()方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在PHP5中,是否保证为每个对象实例调用__destruct()方法?在程序中是否有异常可以防止这种情况发生?

In PHP5, is the __destruct() method guaranteed to be called for each object instance? Can exceptions in the program prevent this from happening?

推荐答案

当所有引用被释放时或者脚本终止。我认为这意味着脚本正常终止。我会说重要的异常不会保证析构函数被调用。

The destructor will be called when the all references are freed, or when the script terminates. I assume this means when the script terminates properly. I would say that critical exceptions would not guarantee the destructor to be called.

PHP文档有点薄,但它确实表示析构函数中的异常会导致问题。

The PHP documentation is a little bit thin, but it does say that Exceptions in the destructor will cause issues.

这篇关于我可以信任调用PHP __destruct()方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆