Home>Article>Backend Development> How to directly modify php.ini to block php errors
How to directly modify php.ini to block PHP errors: first open the php.ini file; then modify the content "display_errors = Off"; finally set "log_errors = On".
The operating environment of this article: Windows7 system, PHP7.1 version, DELL G3 computer
How to directly modify php.ini to block php Report an error?
Modify php.ini to shield the error message
That’s because the error display is turned off in php.ini and the error is written into a file. This is As a result of artificial settings, display_errors =on will be fine.
However, it is safe to not display errors. It is recommended to turn it on during debugging and then turn it off when providing services.
Provide some information for you:
display_errors = On
By default, php turns on the error message display. We changed it to:
display_errors = Off
After turning off the error display, the php function executes The error information will no longer be displayed to the user. This can prevent the attacker from knowing the physical location of the script and some other useful information from the error message, which at least creates certain obstacles for the attacker's black box detection. 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.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to directly modify php.ini to block php errors. For more information, please follow other related articles on the PHP Chinese website!