In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "how to set the warning level in php". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to set the warning level in php".
Php sets the warning level: 1, modify the error_reporting option in php.ini; 2, use the error_reporting () function in the php page to modify the error level.
This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer
How does php set the warning level?
Setting method of php error level
When PHP is running, it will give different prompts for errors of different severity.
Eg: when $an is not declared, it is added directly, the value is NULL, and the sum is counted as 0. However, it prompts NOTICE, that is, to pay attention.
In our development, for the sake of the standardization of the program, we also report the error level, which is adjusted to a higher NOTICE level, which helps us to quickly locate errors and code normations. however, after the product is launched, during the operation of the website, it is not appropriate to report so many errors.
1: this kind of mistake makes a bad impression on customers.
2: when reporting an error, report the absolute path of the website, such as D:\ www\ 1015. Increase the risk of being attacked
Therefore, after the website is online, we should lower the level of reporting errors, underreport errors or even not report them.
Modify the error level:
1: modify the error_reporting option in php.ini
2: you can modify it in the php page with the error_reporting () function.
The error level is expressed in binary values: 1111 1111 1111 111 from left to right, 1 on each represents an error level
Fatal error fatal error: 0000 0000 0000 on 1
Warning warning error: 0000 0000 0000 010 on 2
NOTICE warning: 0000 0000 0001 000 on 8
Eg:
All reported: error_reporting (11)
Do not apply for NOTICE: error_reporting (3)
No errors are reported: error_reporting (0)
The system replaces the values of each level with system constants for us.
E_ERROR 1
E_WARNING 2
E_NOTICE 8
Report all errors: error_reporting (E_ALL)
All except NOTICE: error_reporting (E_ALL & ~ E_NOTICE)
In development, the error reporting level is higher, while in online products, the error reporting level is lower: +
The code is as follows:
Define ('DEBUG',true); / / declare a DEBUG mode if (defined (' DEBUG')) {/ / detected that you are in development mode error_reporting (E_ALL);} else {error_reporting (0);} above is all the content of the article "how to set warning levels in php". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.