Can I trust PHP __destruct() method to be called?(我可以信任调用 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() 方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我可以信任调用 PHP __destruct() 方法吗?
基础教程推荐
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- 在多维数组中查找最大值 2021-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01