当我的 php 代码中出现错误时,我遇到了一个奇怪的问题,我的网页只是显示无法访问的网页,但没有显示错误。我通过以下方式更改了我的 php 初始化文件:
error_reporting = E_ALL & E_NOTICE & E_STRICT
但它不会改变任何东西
您在此处使用了错误的运算符。您的行只会消除类型 E_ALL 和 E_NOTICE 和E_STRICT的错误。由于错误不能匹配所有三种类型,因此不显示任何类型。
使用 or 运算符 |
包含某些内容,或使用 and-not 操作数 '~&' 从E_ALL中排除某些内容。
error_reporting (E_ALL | E_NOTICE | E_STRICT);
如果您正在谈论 php.ini 中的设置,请使用以下文档:
; Common Values:
; E_ALL (Show all errors, warnings and notices including coding standards.)
; E_ALL & ~E_NOTICE (Show all errors, except for notices)
; E_ALL & ~E_NOTICE & ~E_STRICT (Show all errors, except for notices and coding standards warnings.)
; E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR (Show only errors)
; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
; Development Value: E_ALL
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT
; http://php.net/error-reporting
error_reporting = E_ALL
警告:如果您在其他地方指定错误级别,例如 apache 配置,请使用这些常量后面的数字而不是常量!
http://php.net/manual/de/errorfunc.configuration.php#ini.error-reporting