<?php
function handle1()
{
echo 'handle1';
}set_exception_handler('handle1');//throw new Exception('1');
class a
{
function __construct() {
set_exception_handler(array(__CLASS__,'handle'));
} function __destruct() {
restore_exception_handler();
} function handle()
{
echo 'handle2';
} function b()
{
throw new Exception('2');
}
}//---1
//$a = new a();
//$a->b();//---2
function c()
{
$a = new a();
$a->b();
}c();//---3 $a 被释放 后面的 catch 去异常队列取数据 忽略定义的handle ?
//try{
// $a = new a();
// $a->b();
//}catch(Exception $e)
//{
//
//}?>
上面 1 和 2 为什么有不同的结果?
function handle1()
{
echo 'handle1';
}set_exception_handler('handle1');//throw new Exception('1');
class a
{
function __construct() {
set_exception_handler(array(__CLASS__,'handle'));
} function __destruct() {
restore_exception_handler();
} function handle()
{
echo 'handle2';
} function b()
{
throw new Exception('2');
}
}//---1
//$a = new a();
//$a->b();//---2
function c()
{
$a = new a();
$a->b();
}c();//---3 $a 被释放 后面的 catch 去异常队列取数据 忽略定义的handle ?
//try{
// $a = new a();
// $a->b();
//}catch(Exception $e)
//{
//
//}?>
上面 1 和 2 为什么有不同的结果?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货