How to directly modify php.ini to block php errors

藏色散人
Release: 2023-03-11 16:16:01
Original
1450 people have browsed it

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".

How to directly modify php.ini to block php errors

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
Copy after login

By default, php turns on the error message display. We changed it to:

display_errors = Off
Copy after login

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
Copy after login

to:

log_errors = On
Copy after login

and specify the file, find the following line:

;error_log = filename
Copy after login

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
Copy after login

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!

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