温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

php查看错误的方法

发布时间:2020-10-09 18:50:06 来源:亿速云 阅读:110 作者:小新 栏目:编程语言

这篇文章将为大家详细讲解有关php查看错误的方法,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

php查看错误的方法:1、通过配置【php.ini】中的参数设置PHP的报错级别可以在php.ini中适当的位置增加一行;2、通过PHP函数【error_reporting】设定PHP报错级别。

php查看错误的方法:

一、通过配置php.ini中的参数设置PHP的报错级别可以在php.ini中适当的位置增加一行

error_reporting=E_ALL
CODE:[COPY]
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

CODE:[COPY]

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

CODE:[COPY]

//禁用错误报告

error_reporting(0);

//报告运行时错误

error_reporting(E_ERROR | E_WARNING | E_PARSE);

//报告所有错误

error_reporting(E_ALL);

那么我们就可以把论坛里的include/common.inc.php文件里的

error_reporting(0);
CODE:[COPY]
error_reporting(0);

修改成

error_reporting(E_ALL);
CODE:[COPY]
error_reporting(E_ALL);

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

关于php查看错误的方法就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

php
AI