您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
三六零分类信息网 > 遂宁分类信息网,免费分类信息发布

php:析构函数调用的示例代码

2025/11/11 6:57:08发布24次查看
php析构函数调用
class a{ function construct(){ echo "start to construct a obj\n"; } function pide($a,$b) { //exit(1);//destruct called return $a/$b; //destruct called when $b=0; } function add($a,$b) { throw new exception ("daone");//destruct called return $a+$b; } function destruct(){ echo "start to destruct\n"; } } try{ $first = new a(); //$r = $first->pide(4,0); $first->add(4,0); } catch(exception $e) { echo "cath exception \n"; }
从上面的例子可以看出,php抛出异常(不管外面有没有try catch),直接退出的情况下,都会调用析构函数。
以上就是php:析构函数调用的示例代码的详细内容。
遂宁分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product