怎么让discuz显示php错误

2023-05-12,,

小编给大家分享一下怎么让discuz显示php错误,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

让discuz显示php错误的方法:可以利用error_reporting函数来实现。error_reporting函数可以设定php报错级别,如【error_reporting(report_level)】。

一、通过配置 php.ini 中的参数设置PHP的报错级别

可以在 php.ini 中适当的位置增加一行

以下为引用的内容:

error_reporting = E_ALL

  注: php.ini 中实现给出了一些例子,比如我本地的 php.ini 中就有如下

以下为引用的内容:

; Examples:; - Show all errors, except for notices and coding standards warnings;error_reporting = E_ALL & ~E_NOTICE; - Show all errors, except for notices;error_reporting = E_ALL & ~E_NOTICE | E_STRICT; - Show only errors;error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR; - Show all errors except for notices and coding standards warnings;error_reporting = E_ALL & ~E_NOTICE

  我只要在这些行代码的下面增加 error_reporting = E_ALL 然后重新启动 web 服务就可以了

  二、通过 PHP 函数 error_reporting 设定 PHP 报错级别

  如果你无权修改 php.ini 中的参数配置,你可以通过这个函数来设置报错级别。

  error_reporting() 函数使用方法

 error_reporting(report_level)

  如果参数 level 未指定,当前报错级别将被返回。

  任意数目的以上选项都可以用“或”来连接(用 OR 或 |),这样可以报告所有需要的各级别错误。例如,下面的代码关闭了用户自定义的错误和警告,执行了某些操作,然后恢复到原始的报错级别:

以下为引用的内容:

 //禁用错误报告error_reporting(0);//报告运行时错误error_reporting(E_ERROR | E_WARNING | E_PARSE);//报告所有错误error_reporting(E_ALL);那么我们就可以把论坛里的 include/common.inc.php文件里的
  error_reporting(0);

  修改成

  error_reporting(E_ALL);

  然后保存,这样就可以看到 PHP 报告的错误信息了

以上是“怎么让discuz显示php错误”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注本站行业资讯频道!

《怎么让discuz显示php错误.doc》

下载本文的Word格式文档,以方便收藏与打印。