PHP.ini中配置屏蔽错误信息显示和保存错误日志的例子_PHP

WBOY
Release: 2016-06-01 11:53:18
Original
743 people have browsed it

在PHP程序运行过程中如果有错误发生,在浏览器上是否显示错误信息,以及显示错误信息的级别是我们在程序开发、调试、运营过程中需要控制的。
下面就通过设置php.ini,控制PHP错误信息(errors)的屏蔽和显示作如下说明:
1、错误信息是否显示
     复制代码 代码如下:显示错误 display_errors = On
     屏蔽错误 display_errors = Off (缺省值)
2、显示错误信息的级别
     复制代码 代码如下:error_reporting = E_ALL (全部)
     error_reporting = E_ALL & ~E_NOTICE (Notice 以上的错误会显示)
     在这里我们一般设置为E_ALL,在PHP程序中利用error_reporting()函数来设置当前程序的错误信息级别。
3、设置是否保存错误日志
     在程序运营过程中我们一般设置为不显示错误,这样可以通过保存错误日志来记录运行状态
    复制代码 代码如下:log_errors = On (记录错误日志)
    log_errors = Off (不记录)
    如果保存错误日志的话,需要同时设置错误日志保存文件
    复制代码 代码如下:error_log = e:/php/logs/php_error.log

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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!