请考虑以下示例代码:
<?
try {
throw new Exception('new');
} catch (Exception $ex) {
echo "caught";
}
?>
我认为这应该只是在运行时输出字符串“caught”。但是,在显示错误打开的情况下,我看到网页上显示的异常如( ! ) Exception: new in test.php on line 2
以及调用堆栈和范围中的变量。
关闭显示错误后,它不会显示异常通知。即使出现显示错误,try catch块也不应该阻止显示通知吗?
答案 0 :(得分:1)
如果您正在使用xdebug并且您不想禁用xdebug或错误报告,并且您不希望显示捕获的异常的跟踪消息,则可以使用
关闭异常跟踪的显示xdebug.show_exception_trace = 0
在你的php.ini
中