Home >Backend Development >PHP Problem >How to output errors to a file in php
How to output errors to a file in php: 1. Find php.ini in the php configuration file; 2. Enter the error information into the log file by setting "log_errors = On".
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
How does php output errors to a file?
Enter PHP errors into the log file
(LAMP) prohibits the client browser from displaying PHP code errors and saves the error information to the log file :
Find php.ini in the php configuration file (such as /etc/php.ini under Centos6.7), set
display_errors = Off //不允许在浏览器中显示错误信息 log_errors = On //将错误信息输入到log文件中 error_log = /var/www/html/php_errors_log//指定错误日志位置
Find the apache configuration file http.conf( For example, in /etc/httpd/conf/httpd.conf under Centos6.7, set
php_flag display_errors off php_value error_reporting 2039
to restart the apache server
service httpd restart
Note:
1. If the directory specified by log_errors exists or does not have permission, the error will still be output to the browser.
2. The Centos user who writes error logs to the log_errors file is apache (not the apache server, but A user of Centos), so pay attention to the permissions of the apache user
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to output errors to a file in php. For more information, please follow other related articles on the PHP Chinese website!