我很困惑。什么可能导致“catch”不起作用?我该如何修复它?
<?php
try {
throw new Exception('BOOM');
error_log("should not happen");
} catch(Exception $e) {
error_log("should happen: " . $e->getMessage());
}
?>
实际产量
[27-Apr-2010 09:43:24] PHP Fatal error: Uncaught exception 'Exception' with message 'BOOM' in /mycode/exception_problem/index.php:4
Stack trace:
thrown in /mycode/exception_problem/index.php on line 4
期望输出
should happen: BOOM
php版本5.2.3
在php_info()中,我看不到任何可能被禁用的异常。
我试过使用“restore_exception_handler();”但这并不能使catch块工作。
我也尝试过使用“set_exception_handler(null);”,但这两种方法都不能使catch块工作。
如何获得所需的输出?