error-handling - 当error_reporting = off时,AJAX调用的文件显示错误

标签 error-handling php error-reporting

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_STRICTE_ALL的一部分,因此如果您配置方式,也必须将其从中删除:

error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT
                                                    ^^^^^^^^^^^

因此,如果您从生产错误设置中排除E_STRICT,则不应再记录这些严格标准错误-这可能就像您在较早的PHP 5.3版本中遇到的那样。

另外,您应该与库的供应商联系,并要求使代码E_STRICT兼容。这是一个好习惯,并且还向您显示某些代码具有一定的质量。

对于您的开发,您应该同样使您的代码E_STRICT兼容,并修复导致“严格标准”错误的任何位置。
E_NOTICEE_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

从问题中提供的信息中,您看不到输出错误消息而不是记录错误消息的原因。这可能有多种原因,
  • 最直接的原因是您没有正确禁用错误显示-或在运行时再次启用它(该设置也可以在PHP代码中更改)。
  • 错误显示被禁用,但是仍有some error handlerDocs仍在显示它们。

  • 因此,除了错误级别设置外,问题的这一部分还需要在您端进行更多的故障排除,以找出为什么显示错误消息。

    也可以看看:
  • How to disable E_STRICT(2010年5月17日;作者rtacconi)
  • Error Reporting - PHP The Right Way
  • 关于error-handling - 当error_reporting = off时,AJAX调用的文件显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14131936/

    相关文章:

    在应用程序的每个模块中对错误(常量错误)进行分组的好方法

    image - RMSE Landsat8 AVHRR

    oracle - 发生错误时如何退出sqlplus

    PHP/MySQLi 表单 SQL 语法错误 - 关于为什么它不起作用的建议、答案或建议?

    r - 错误后继续在R中循环(例如,使用数字和字母的向量)

    php - 如何在 Yii2 中使用 GridView 上的按钮选项

    php - 将多个 MySQL 查询合并到一个不同的表中

    PHP 不显示错误 - 内部服务器错误 (500)

    php - mysqli_fetch_assoc()需要参数/调用成员函数bind_param()错误。如何获取并修复实际的mysql错误?

    php - error_reporting() 和 ini_set ('error_reporting' 之间的区别)?