php已经捕获了异常还是一样的输出异常错误的原因

4032 次阅读 by 九九 2012-09-30 | 标签:问题 PHP

先给出官方的E文定义:

  • display_errors string

  • This determines whether errors should be printed to the screen as part of the output or if they should be hidden from the user. Value "stderr" sends the errors to stderr instead of stdout. The value is available as of PHP 5.2.4. In earlier versions, this directive was of type boolean.

    Note: This is a feature to support your development and should never be used on production systems (e.g. systems connected to the internet).
    Note: Although display_errors may be set at runtime (with ini_set()), it won't have any affect if the script has fatal errors. This is because the desired runtime action does not get executed.
  • 基本的翻译“”

  • 第一句话讲的确实已经很清楚“这个设置决定了是否在屏幕上显示当前的错误信息”,但我在处理一个异常信息时,我已经对当前的异常信息加上了

    try {
        //some throw new HXxxException();
    } catch(HXxxxException $ex) {
       var_dump($ex->getMessage());
    }

  • 但是异常的报错信息还是被打印在了屏幕上。我一开始还以为是
  • xdebug
  • 的原因,我把
  • xdebug
  • 的扩展给去了,可它还是一样的输出。最后,我通过查配置,发现了:
  • display_errors=On;
  • 就试着关了一下,哈哈,没有异常的打印信息了...正常的捕获加输出.....原来
  • display = On
  • 这么的霸气,捕获都无视的!!!!难怪:
  • This is a feature to support your development and should never be used on production systems!!!

评论(2)

Kert To 九九 (2017-06-14)

Neil, something is definitely ferkakt with your blog (maybe due to the bltucoka?); I was not the first with a comment — there had been 3 ahead of mine when I looked, but suddenly I hit “Say It!” and I was right up there.

PS:多打字可以减肥哦~234字以内。支持表情:


Top