PHP异常显示在try和catch块中
I have a very strange situation: code shown below should print no error in PHP.
try {
throw new Exception('foo');
} catch(Exception $e) {
// here could be some custom functions to handle errors
die();
}
On my computer it prints
( ! ) SCREAM: Error suppression ignored for
( ! ) Exception: foo. in D:\wamp\www\index.php on line 4
Why? Which php ini option does that?
我有一个非常奇怪的情况:下面显示的代码在PHP中不会出错。 p> \ n
尝试{
抛出新的异常('foo');
} catch(Exception $ e){
//这里可能是一些自定义函数来处理错误
die(); \ n}
code> pre>
在我的计算机上打印 p>
(!)SCREAM:
忽略错误抑制(n) !)例外:foo。 在第4行的D:\ wamp \ www \ index.php
code> pre>
为什么? 哪个php ini选项可以做到这一点? p>
div>
The Scream extension is an extension aimed at developers, so that they get to see error messages from their code even when they would normally be suppressed.
xDebug is another developer extension that also includes the same functionality.
If you have either of these extensions, the Scream feature can be disabled in your PHP config.
But neither of those extensions should be in use on a production system -- they are intended for use on a developer's system only. If it's on your live site, then the extension should be disabled entirely.
http://www.php.net/manual/en/scream.examples-simple.php
Usually, scream is used to override the silence operator (@), but if its doing it for try catch, as well...you can try to use an in-line ini_set to turn it off and see if that fixes it.
Thank you all for answers. Yes, the problem was xdebug, to be more accurate: xdebug.show_exception_trace
option., which was turned to on
.
As we read from xdebug documentation:
xdebug.show_exception_trace
Type: integer, Default value: 0
When this setting is set to 1, Xdebug will show a stack trace whenever an exception is raised - even if this exception is actually caught.