【问题标题】:show all errors except notice and strict in php在php中显示除notice和strict之外的所有错误
【发布时间】:2017-10-12 15:05:30
【问题描述】:

我想记录除notice 和strict 之外的所有php 错误 我尝试了以下代码

error_reporting(E_ALL &^ E_NOTICE &^ E_STRICT);

但它给了我一个错误“意外的^”

【问题讨论】:

    标签: php error-handling error-log


    【解决方案1】:

    请试试这个 error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT); ~ 使用这个标志除了 http://php.net/manual/en/function.error-reporting.php

    【讨论】:

      【解决方案2】:

      您需要使用& ~ 而不是&^

      error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT);
      

      【讨论】:

      • ^ 和 &~ 的区别是什么 error_reporting(E_ALL ^ E_NOTICE ); error_reporting(E_ALL &~ E_NOTICE);
      • ^~ 是位运算符,~ 表示 not ,所以 E_ALL & ~E_NOTICE 表示 E_ALL 而不是 E_NOTICE,而 ^ 表示 XOR,E_STRICT ^ E_NOTICE 表示不打印 E_STRICT 和 E_NOTICE
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-17
      • 1970-01-01
      • 2010-12-08
      • 2016-11-20
      • 2015-02-10
      • 1970-01-01
      • 2013-02-01
      相关资源
      最近更新 更多