php异常处理,错误报告

时间:2012-10-19 17:49:26

标签: php exception exception-handling error-handling

请考虑以下示例代码:

<?    
try {
        throw new Exception('new');
    } catch (Exception $ex) {
        echo "caught";
    }
?>

我认为这应该只是在运行时输出字符串“caught”。但是,在显示错误打开的情况下,我看到网页上显示的异常如( ! ) Exception: new in test.php on line 2以及调用堆栈和范围中的变量。

关闭显示错误后,它不会显示异常通知。即使出现显示错误,try catch块也不应该阻止显示通知吗?

1 个答案:

答案 0 :(得分:1)

如果您正在使用xdebug并且您不想禁用xdebug或错误报告,并且您不希望显示捕获的异常的跟踪消息,则可以使用

关闭异常跟踪的显示
xdebug.show_exception_trace = 0

在你的php.ini