【发布时间】:2013-07-19 01:26:20
【问题描述】:
在我的关闭函数中抛出了一个异常,并且没有在 try/catch 块中被捕获,例如:
<?php
set_exception_handler(function($e){
echo "exception handled"; // not echoed
});
register_shutdown_function(function(){
throw new Exception("test"); // this should be caught by the exception handler above, but it doesn't
});
运行上面的代码给出:
致命错误:未捕获的异常“异常”和消息“测试”
但是PHP Manual 声称:
set_exception_handler 设置默认异常处理程序如果在 try/catch 块中没有捕获到异常。 执行将在 exception_handler 后停止调用。
为什么exception_handler 没有捕捉到抛出的异常?
【问题讨论】:
标签: php exception exception-handling shutdown php-internals