无法在PHP 5.3.2中关闭通知错误

时间:2010-04-23 16:20:36

标签: php error-handling

我最近迁移到PHP 5.3.2,并意识到我现在无法在我的网站中关闭通知错误。我去了php.ini,在这些行中:

; Common Values:
;   E_ALL & ~E_NOTICE  (Show all errors, except for notices and coding standards warnings.)
;   E_ALL & ~E_NOTICE | E_STRICT  (Show all errors, except for notices)
;   E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR  (Show only errors)
;   E_ALL | E_STRICT  (Show all errors, warnings and notices including coding standards.)
; Default Value: E_ALL & ~E_NOTICE
; Development Value: E_ALL | E_STRICT
; Production Value: E_ALL & ~E_DEPRECATED
; http://php.net/error-reporting
error_reporting = E_ALL & ~E_NOTICE

...我已尝试设置所有内容(我每次都重启apache),但我无法删除通知。

我能摆脱通知错误的唯一方法是设置:

display_errors = Off

当然,这不是我能做的事情,因为我需要看错误来修复它们,我希望在网页上看到我编码的错误,而不是将它们记录在某处。

有人可以帮忙吗?这是PHP 5.3.2中的错误还是我做错了什么?

非常感谢你的时间!

P上。 S.另外,有谁知道如何让PHP 5.3.2支持.php3扩展?

2 个答案:

答案 0 :(得分:3)

好的,我知道出了什么问题。我在我的代码中设置了error_reporting,它覆盖了php.ini error_reporting。

在我升级到PHP 5.3.2之前,同样的东西工作的原因是 - 在我的代码中,我设置了error_reporting命令:

  

的error_reporting(6143);

我应该将其设置为:

  

error_reporting(E_ALL ^ E_NOTICE);

我猜测6143中的6143的含义与4.1版(或者我之前的版本中的任何版本)相比有所不同。

至于php3扩展,它应在/etc/httpd/conf.d/php.conf文件中设置:

  

AddHandler php5-script .php .php3

     

AddType text / html .php

感谢sourcez,感谢您的建议!

答案 1 :(得分:0)

我今天在我的网站上也遇到了同样的错误,我使用TCPDF库来生成PDF。它工作正常但突然我今天开始收到以下错误

Severity: 8192
Message: Imagick::clone method is deprecated .....

可能是主机提供商更新了PHP或Imagick。 PHP - 5.4和Imagick - 3.x

所以为了在我的代码中摆脱这个,我将error_reporting设置为

error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);

这将显示错误,但不会显示已弃用的通知。同时我可以更改我的代码以支持新版本的Imagick。

相关问题