php error level setting method

  • 2020-06-12 08:46:18
  • OfStack

At run time, PHP gives different notifications for errors of different severity.

eg: When $a is not declared, add the value NULL and count as 0.

In our development, for the sake of the standardization of the program, we report the error level and the higher LEVEL of NOTICE, which helps us to quickly locate errors and code specifications. However, after the launch of the product, it is not appropriate to report so many errors during the operation of the website.

1: This kind of mistake gives the customer a bad impression
2: When reporting an error, the absolute path of the website, such as D:\www\1015, is reported, increasing the risk of attack
Therefore, after the launch of the website, should let the error level lower, less error or even no report.

Modify error reporting level:

1: Modify error_reporting option in ES20en. ini
2: You can use the error_reporting() function on the php page

The error level is represented in base 2:1111 1111 1111 111 from left to right, 1 above each, representing one error level

fatal error fatal error: 0000 0000 0000 001 on 1
warning warning error: 0000 0000 0000 010 on 2
NOTICE warning: 0000 0000 0001 000 turn on 8


Do not report NOTICE: error_reporting(3);
No errors are reported: error_reporting(0);

The system replaces the values of each level for us with system constants.


Report all errors: error_reporting(E_ALL);

All but NOTICE are quoted: error_reporting(E_ALL & ~E_NOTICE);

In development, the error reporting level is 1 point higher, and in the online product, the error reporting level is lower :+

  define('DEBUG',true); //  At the time of development , The statement 1 a DEBUG model  
    if(defined('DEBUG')) { // Detected in development mode  
    } else { 

Related articles: