How to block program errors in php

王林
Release: 2023-03-09 15:48:02
Original
1725 people have browsed it

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

How to block program errors in php

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

By default, php opens the error message display. We change it to:

display_errors = Off
Copy after login

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

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!