In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to modify php.ini to block error messages and record logs. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
That's because the error display is turned off in php.ini and the error is written into a file, which is the result of artificial setting, display_errors = on.
However, do not display the error inverted safe point, it is recommended to turn it on when debugging, and then turn it off when providing services.
To provide you with a little information:
Display_errors = On
Php turns on the error message by default, and we change it to:
Display_errors = Off
After turning off the error display, the php function execution error information will no longer be displayed to the user, which can prevent the attacker from knowing the physical location of the script and some other useful information to a certain extent, at least causing some obstacles to the attacker's black box detection. These error messages may be useful to ourselves, we can write them to the specified file, then modify the following:
Log_errors = Off
Change 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
So that all errors will be written to the php_error.log file.
= =
Error_reporting
Configure the level of error message return.
Syntax: int error_reporting (int [level])
Return value: integer
Function type: PHP system function
This function is used to configure the level of error message return. The parameter level is an integer bit mask (bitmask), as shown in the table below.
The mask value represents the name
1 E_ERROR
2 E_WARNING
4 E_PARSE
8 E_NOTICE
16 E_CORE_ERROR
32 E_CORE_WARNING
E_NOTICE means that the general situation is not recorded and is used only when there is an error in the program, such as attempting to access a variable that does not exist, or calling the stat () function to view a file that does not exist.
E_WARNING is usually displayed, but does not interrupt the execution of the program. This is very effective for debugging. For example: call ereg () with a problematic regular expression.
E_ERROR usually shows up and interrupts program execution. This means that memory configuration or other errors cannot be traced with this mask.
E_PARSE parses errors from syntax.
E_CORE_ERROR is similar to E_ERROR, but does not include errors caused by the PHP core.
E_CORE_WARNING is similar to E_WARNING, but does not include PHP core error warnings.
-
Additional:
1.
In the php file
7 of error_reporting (7) is 1 / 2 / 4, which means a return of 1 E_ERROR 2 E_WARNING 4 E_PARSE
two。
In php.ini
Display_errors = Off / / turns off the error prompt by default
Error_reporting = E_ALL / / displays all the information from bad coding practices to harmless prompts to errors. Because the return information is too detailed, including harmless information, in order to see the actual hints in the development process, it is recommended to configure it as error_reporting = E_ALL & ~ E_NOTICE
This is the end of the article on "how to modify php.ini to block error messages and log". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.