Home > php教程 > php手册 > PHP中显示出错提示方法介绍

PHP中显示出错提示方法介绍

WBOY
Release: 2016-05-25 16:52:45
Original
936 people have browsed it

php.ini配置

php.ini配置中与此相关的有两个配置变量,下面是这两个变量及其默认值,以下是引用片段:

display_errors = Off

error_reporting = E_ALL & ~E_NOTICE

display_errors 变量的目的很明显 —— 它告诉PHP是否显示错误。默认值是 Off。现在我们的目的是显示错误提示,那么:

display_errors = On

E_ALL,这个设置会显示从不良编码实践到无害提示到出错的所有信息,E_ALL 对于开发过程来说有点太细,因为它连变量未初始化也显示提示,而这一点正是PHP“高级”的一个特征。幸好,error_reporting的默认值是“E_ALL & ~E_NOTICE”,这样就只看到错误和不良编码了,对程序无不利的提示则不会显示。

修改php.ini后需要重新启动Apache,这样才可以在apache中生效,当然你如果只在命令行下测试程序,是不需要这一步的。

显示值,宏定义:

1 E_ERROR

2 E_WARNING

4 E_PARSE

8 E_NOTICE

16 E_CORE_ERROR

32 E_CORE_WARNING

64 E_COMPILE_ERROR

128 E_COMPILE_WARNING

256 E_USER_ERROR

512 E_USER_WARNING

1024 E_USER_NOTICE

6143 E_ALL

2048 E_STRICT

4096 E_RECOVERABLE_ERROR

永久链接:

转载随意!带上文章地址吧。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template