【问题标题】:display_errors value isn't changing in phpinfo()phpinfo() 中的 display_errors 值没有改变
【发布时间】:2016-08-02 05:15:25
【问题描述】:

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

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

我在 php.ini 中将 display_errors 更改为 Off。 但是 phpinfo() 中 display_errors 的值不会改变: display_errors On On 本地值和主值都打开。

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

【问题讨论】:

  • 请编辑问题并在此处发布您的 php.ini 文件。它可以帮助我们,也可以帮助您更快地找到解决方案! :)
  • 更改另一个 php.ini 文件。您更改的那个由 PHP CLI 使用。通过查看phpinfo() 输出可以找到Apache 使用的那个。抱歉不能更具体地说明它的位置我是一个愚蠢的 Windows 用户
  • @RiggsFolly 说了什么,然后重新启动 Apache。
  • 您当然要关闭这些错误显示,因为这是一个实时站点,对吧?您不会仅仅为了隐藏代码中的 100 个错误而这样做吗?不,当然不是,傻我
  • @RiggsFolly :在我的 phpinfo() 中,这是提到的 php.ini 文件。 phpinfo() 中的值: 加载的配置文件:/usr/local/php5/lib/php.ini 扫描此目录以获取其他 .ini 文件:/usr/local/php5/php.d

标签: php php-ini phpinfo


【解决方案1】:

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

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 文件的那部分仅用于文档,请在ini 文件中的该部分之后查找对要更改的每个参数的另一个引用。
  • 这正是 OP 提供的。我很少做假设。我接受提供给我的东西。但是,尽管我为他解决了问题,但还是感谢您的反对。
  • 是的,所以 OP 也不知道如何处理 php.ini 文件。寻找我提到的其他参考,看看我是否正确
  • 我只提到这一点,以防其他人看到这个答案并犯同样的错误。作为文件中较低的参数,当然,文件后面的参数将优先于本节中所做的任何更改。
【解决方案2】:

分号是php.ini中的备注

; display_errors
;   Default Value: Off

之后的一切;被忽略。

【讨论】:

    【解决方案3】:

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

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

    此部分仅用于文档,而不是实际参数所在的位置。如果你在文件中往下看,你会看到真正的参数位置

    ; 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
    

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

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

    【讨论】:

      猜你喜欢
      • 2010-11-08
      • 1970-01-01
      • 2011-04-17
      • 1970-01-01
      • 2018-09-28
      • 1970-01-01
      • 2014-12-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多