Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set the error level in php.ini

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces php.ini how to set the error level, the text is very detailed, has a certain reference value, interested friends must read!

How to set the error level: 1. Open the PHP installation directory, find and open the "php.ini" configuration file;2. Search the "error_reporting" item in the configuration file, and change the value of the item to the required error level, such as "E_ALL"| E_STRICT"is the most restrictive error level.

Operating environment of this tutorial: Windows 7 system, PHP7.1 version, DELL G3 computer

PHP defines many different levels of error, such as using an undefined variable will report a notice level error, instantiating an undefined class will report a fatal error level error.

So what's wrong with php.ini?

1. Open the PHP installation directory, find and open the php.ini configuration file

2. In the configuration file, search for "error_reporting" item

Change the value of "error_reporting" item to the required error level, for example,"E_ALL| E_STRICT"is the most restrictive error level.

If you do not want to manipulate the php.ini configuration file, you can use the error_reporting() function

Add the following code to the page where you want to disable notice error messages

/* Report all errors except E_NOTICE */error_reporting(E_ALL ^ E_NOTICE);

Additional knowledge: Error types in PHP

Value constant 1E_ERROR Fatal runtime error, usually an unrecoverable condition, such as a memory allocation problem, which causes the script to terminate and no longer run. 2E_WARNING Run-time warning (nonfatal error), only a prompt is given, but the script does not terminate. 4E_PARSE Compile-time syntax parsing error, generated only by parsers. 8E_NOTICE Runtime notification, indicating that the script encountered a situation that might appear as an error, but there may be similar notifications in scripts that work properly. 16E_CORE_ERROR Fatal error during PHP initialization startup, similar to E_ERROR, but generated by the PHP engine core. 32E_CORE_WARNINGPHP initializes a warning (nonfatal error) that occurs during startup, similar to E_WARNING, but generated by the PHP engine core. 64E_COMPILE_ERROR Fatal compile-time error similar to E_ERROR, but generated by the Zend scripting engine. 128E_COMPILE_WARNING Compile-time warnings (nonfatal errors), similar to E_WARNING, but generated by the Zend scripting engine. 256E_USER_ERROR User-generated error messages, similar to E_ERROR, but generated by the user himself using the PHP trigger_error() function in his code. 512E_USER_WARNING User-generated warning messages, similar to E_WARNING, but generated by the user himself using the PHP trigger_error() function in his code. 1024 E_USER_NOTICE User-generated notification messages, similar to E_NOTICE, but generated by the user himself using the PHP trigger_error() function in his code. 1024E_STRICT Enables PHP to suggest changes to code to ensure optimal interoperability and forward compatibility. 2048E_RECOVERABLE_ERROR Catchable fatal error, indicating that a potentially dangerous error occurred, but has not caused the PHP engine to be in an unstable state. If the error is not caught by the user-defined handle, it becomes an E_ERROR, causing the script to terminate. 8192E_DEPRECATED Runtime notification, enabled to warn against code that may not work correctly in future releases. 16384E_USER_DEPRECATED A user-generated warning message, similar to E_DEPRECATED, but generated by the user himself using the PHP trigger_error() function in his code. All error and warning messages except 30719E_ALLE_STRICT.

The values (numerical or symbolic) in the table are used to establish a binary bit mask that specifies the error message to report. Bitwise operators can be used to combine these values or mask certain types of errors.

Note that in php.ini, only '|'、'~'、'! ','^'and'&'resolve correctly.

In the formal environment, various unknown errors may occur, then you can define error_reporting(0), so that you can shield the error, the user will not see the error message on the page, and when troubleshooting errors, you can still find relevant information in PHP's execution error log.

The above is "php.ini how to set the error level" all the content of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report