How to use php to output errors to a file
How to use php to output errors to a file, in view of this problem, this article introduces the corresponding analysis and solutions in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.
Php will output the error to the file method: 1, find php.ini;2 in the php configuration file, by setting "log_errors = On" to input the error information into the log file.
This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer
How does php output errors to a file?
Input PHP errors into the log file
(LAMP) prevent client browsers from displaying PHP code errors and save error messages to log files:
Find php.ini in the php configuration file (such as in / etc/php.ini under Centos6.7), and set
Display_errors = Off / / error messages are not allowed to be displayed in browsers log_errors = On / / input error messages into log files error_log = / var/www/html/php_errors_log// specify error log location
Find the configuration file http.conf of apache (such as / etc/httpd/conf/httpd.conf under Centos6.7), and set
Php_flag display_errors off php_value error_reporting 2039
Restart the apache server
Service httpd restart
Note:
1. If the directory specified by log_errors exists or does not have permissions, the error will still be output to the browser
2. The Centos user who writes the error log to the log_errors file is apache (not an apache server, but a user of Centos), so pay attention to the permissions of the apache user.
This is the answer to the question about how to use php to output errors to files. I hope the above content can be of some help to you. If you still have a lot of doubts to solve, you can follow the industry information channel to learn more about it.