design231 2013-01-08 11:34:54 8706次浏览 4条回复 0 0 0

请问怎么关错误提示呀?像notice什么的,就直接屏蔽掉?

在入口文件那屏蔽掉:defined('YII_DEBUG') or define('YII_DEBUG',true); 但是出现500错误时就没办法了。

开发情况是,我在controller里做数据库增删改时,同时更新memcache里的值。当memcache连接失败时,并不影响数据库的操作,现在的情况是,memcache连不上时,直接500错误,程序停掉了。 请高手帮忙谢谢

  • 回复于 2013-01-08 11:58 举报

    php.ini中配置:error_reporting = E_ALL & ~E_NOTICE 除了NOTICE,其他都显示。
    还有很多错误级别:

    ; E_ALL             - All errors and warnings (doesn't include E_STRICT)
    ; E_ERROR           - fatal run-time errors
    ; E_RECOVERABLE_ERROR  - almost fatal run-time errors
    ; E_WARNING         - run-time warnings (non-fatal errors)
    ; E_PARSE           - compile-time parse errors
    ; E_NOTICE          - run-time notices (these are warnings which often result
    ;                     from a bug in your code, but it's possible that it was
    ;                     intentional (e.g., using an uninitialized variable and
    ;                     relying on the fact it's automatically initialized to an
    ;                     empty string)
    ; E_STRICT          - run-time notices, enable to have PHP suggest changes
    ;                     to your code which will ensure the best interoperability
    ;                     and forward compatibility of your code
    ; E_CORE_ERROR      - fatal errors that occur during PHP's initial startup
    ; E_CORE_WARNING    - warnings (non-fatal errors) that occur during PHP's
    ;                     initial startup
    ; E_COMPILE_ERROR   - fatal compile-time errors
    ; E_COMPILE_WARNING - compile-time warnings (non-fatal errors)
    ; E_USER_ERROR      - user-generated error message
    ; E_USER_WARNING    - user-generated warning message
    ; E_USER_NOTICE     - user-generated notice messag
    
  • 回复于 2013-01-08 13:02 举报

    现在的情况是,memcache连不上时,直接500错误,程序停掉了。不想要memcache 影响到正常的数据库处理。

  • 回复于 2013-01-08 13:23 举报

    谢谢版主大人,按你说的方法好了

    在入口文件里屏蔽:

    error_reporting (0);
    defined('YII_DEBUG') or define('YII_DEBUG',true);
    
  • 回复于 2016-10-09 18:40 举报

    配置中增加:
    'errorHandler' => [

    'errorAction' => '/site/error'
    

    ],
    但是notice错并不执行该回调,楼主知道怎么解决吗?

您需要登录后才可以回复。登录 | 立即注册