display_errors 值在 phpinfo() 中没有改变

display_errors value isn't changing in phpinfo()

我需要在 PHP 中关闭 display_errors。我更改了 php.ini (/usr/local/php5/lib/php.ini) 文件。

还通过 phpinfo() 确认正确的文件正在更改: 加载的配置文件 --> /usr/local/php5/lib/php.ini

我在 php.ini 中的所有地方都将 display_errors 更改为关闭。 但是 display_errors 的 phpinfo() 中的值没有改变: display_errors 开启 本地值和主值均开启。

php.ini中的值:

; display_errors
;   Default Value: Off
;   Development Value: Off
;   Production Value: Off

; display_startup_errors
;   Default Value: Off
;   Development Value: Off
;   Production Value: Off

; error_reporting = 0
;   Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
;   Development Value: E_ALL
;   Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT

我玩了大概 2 个小时。任何帮助都会很棒。 谢谢

您是否删除了前面的分号?

display_errors = Off
;   Default Value: Off
;   Development Value: Off
;   Production Value: Off

display_startup_errors = Off
;   Default Value: Off
;   Development Value: Off
;   Production Value: Off

error_reporting = 0
;   Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
;   Development Value: E_ALL
;   Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT

分号是php.ini

中的备注
; display_errors
;   Default Value: Off

之后的一切;被忽略。

请注意,您在问题中显示的部分就在这样的标题下方

;;;;;;;;;;;;;;;;;;;
; Quick Reference ;
;;;;;;;;;;;;;;;;;;;
; The following are all the settings which are different in either the production
; or development versions of the INIs with respect to PHP's default behavior.
; Please see the actual settings later in the document for more details as to why
; we recommend these changes in PHP's behavior.

; display_errors
;   Default Value: On
;   Development Value: On
;   Production Value: Off

; display_startup_errors
;   Default Value: Off
;   Development Value: On
;   Production Value: Off

; error_reporting
;   Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
;   Development Value: E_ALL
;   Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT

此部分仅供参考,并非真正参数所在的位置。如果您查看文件的下方,您将看到真正的参数 locations

; This directive controls whether or not and where PHP will output errors,
; notices and warnings too. Error output is very useful during development, but
; it could be very dangerous in production environments. Depending on the code
; which is triggering the error, sensitive information could potentially leak
; out of your application such as database usernames and passwords or worse.
; For production environments, we recommend logging errors rather than
; sending them to STDOUT.
; Possible Values:
;   Off = Do not display any errors
;   stderr = Display errors to STDERR (affects only CGI/CLI binaries!)
;   On or stdout = Display errors to STDOUT
; Default Value: On
; Development Value: On
; Production Value: Off
; http://php.net/display-errors
display_errors = On

这是您应该对实际参数进行更改的地方,因为如果您更改您提到的部分,参数更改将被下面指定的 真实 参数覆盖。

Also dont forget to restart Apache after saving any changes to the php.ini or the changes will not take effect.