Home > Article > Backend Development > How to block program errors in php
How to shield program errors in php: First open the php configuration file php.ini; then find the [display_errors=on] option in the configuration file; finally change the option to [display_errors=off].
The operating environment of this article: windows10 system, php 7.3, thinkpad t480 computer.
First we open the php configuration file php.ini and find the following options
display_errors = On
By default, php opens the error message display. We change it to:
display_errors = Off
Close the error After displaying, the PHP function execution error message will no longer be displayed to the user. This can prevent attackers from knowing the physical location of the script and some other useful information from the error message, at least for black box detection by attackers. cause certain obstacles. These error messages may be useful to ourselves. We can let it be written to the specified file, then modify the following:
log_errors = Off
to:
log_errors = On
and specify the file, find the following line:
;error_log = filename
Remove the previous; comment and change the filename to the specified file, such as /usr/local/apache/logs/php_error.log
error_log = /usr/local/apache/logs/php_error.log
In this way, all errors will be written to the php_error.log file inside.
Free learning video sharing: Introduction to programming
The above is the detailed content of How to block program errors in php. For more information, please follow other related articles on the PHP Chinese website!