Home > Article > Backend Development > Error level in php, php error level_PHP tutorial
In the process of php programming, everyone will definitely encounter more or less error reminders, and it is these error reminders, To guide us in writing cleaner code, today we will first write down the main error types we listed, dig holes first, write relevant knowledge about PHP errors and exceptions, and slowly fill in the holes.
Deprecated lowest level error, program continues execution
Notice notification level error If undeclared variables are used directly, the program continues to execute
Warning warning level error, you may not get the desired results
Fatal error Fatal error Fatal error, the program will not execute further
Parse error syntax parsing error, the highest level error, even other error messages are not displayed
E_USER_ related errors User settings related errors
Use the trigger_error() function to set a user-level error/warning/notice information
How to set the error level?
error_reporting(-1) displays all errors, error_reporting(0) masks all errors. ini_set('error_reporting',0) also masks all errors. You can set error_reporting in the php.ini file to make the script display or not display certain errors. ini_set('display_errors','On') displays errors.
Note: error_reporting() sets what kind of errors are reported, and ini_set('display_errors','On') sets whether errors are output. Thus error_reporting(-1) and ini_set('display_errors',0) can be used to set the log: errors are reported and not output.
Example: error_reporting(E_ALL&~E_NOTICE) does not display notification level errors. "~" means not.