简体   繁体   中英

PHP Exception shows anyway in try & catch block

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM