在php.ini
中,我的错误显示设置如下:
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED
display_errors = Off
它适用于任何通常调用的文件,但是,如果使用jQuery/AJAX调用文件,则会收到以下错误消息:Strict Standards: Non-static method XML_Util::replaceEntities() should not be called statically, assuming $this from incompatible context in /usr/lib/php/XML/Util.php on line 664
Strict Standards: Non-static method XML_Util::createTagFromArray() should not be called statically, assuming $this from incompatible context in /home/site/public_html/site/paypal/lib/Serializer/Serializer.php on line 1231
Strict Standards: Non-static method XML_Util::attributesToString() should not be called statically, assuming $this from incompatible context in /usr/lib/php/XML/Util.php on line 652
可以假设,这是我网站的一部分,我该如何解决?
我正在运行PHP 5.4.10
使用Jquery函数调用文件:
$.get
或$.post
最佳答案
您使用的代码/库正在触发严格标准错误/通知/警告。
与之相关的错误报告常量称为 E_STRICT
Docs,它是introduced in PHP 5.0Docs。
由于PHP 5.4 E_STRICT
是E_ALL
的一部分,因此如果您配置方式,也必须将其从中删除:
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT
^^^^^^^^^^^
因此,如果您从生产错误设置中排除
E_STRICT
,则不应再记录这些严格标准错误-这可能就像您在较早的PHP 5.3版本中遇到的那样。另外,您应该与库的供应商联系,并要求使代码
E_STRICT
兼容。这是一个好习惯,并且还向您显示某些代码具有一定的质量。对于您的开发,您应该同样使您的代码
E_STRICT
兼容,并修复导致“严格标准”错误的任何位置。E_NOTICE
和E_DEPRECATED
同样适用,您应该在开发环境中启用这些消息并修复所有报告的问题。这样可以避免您过于轻松地获取越来越多的错误。从
php.ini
:;;;;;;;;;;;;;;;;;;;
; 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.
...
; error_reporting
; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
; Development Value: E_ALL
; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT
从问题中提供的信息中,您看不到输出错误消息而不是记录错误消息的原因。这可能有多种原因,
因此,除了错误级别设置外,问题的这一部分还需要在您端进行更多的故障排除,以找出为什么显示错误消息。
也可以看看:
关于error-handling - 当error_reporting = off时,AJAX调用的文件显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14131936/