display_errors值在phpinfo()中没有变化

时间:2016-04-11 20:46:05

标签: php php-ini phpinfo

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

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

我在php.ini中将display_errors更改为Off。 但是show_errors的phpinfo()中的值不会改变: display_errors On on for local value和master value。

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个小时。任何帮助都会很棒。 感谢。

3 个答案:

答案 0 :(得分: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

答案 1 :(得分:0)

半冒号是php.ini中的备注

; display_errors
;   Default Value: Off

之后的一切;被忽略了。

答案 2 :(得分:0)

请注意,您在问题中显示的部分位于此类标题下方

;;;;;;;;;;;;;;;;;;;
; 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

此部分仅适用于documentaion,而不是真实参数所在的位置。如果你在文件中看起来较低,你会看到真实的参数位置

; 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

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

  

也不要忘记在保存对php.ini的任何更改后重启Apache,否则更改将不会生效。