First of all, you must know that the error_reporting() function is used to set the error level and return the current level. It has 14 error levels, as follows:
1 E_ERROR Fatal runtime error. The error cannot be recovered from. Execution of the script was suspended
2 E_WARNING Non-fatal runtime error. The execution of the script will not stop
4 E_PARSE Parsing error during compilation. Parsing errors should only be generated by the analyzer
8 E_NOTICE runtime notifications.
16 E_CORE_ERROR Fatal error when starting PHP. This is like an E_ERROR
32 in the PHP core E_CORE_WARNING A non-fatal error when PHP starts. This is like an E_WARNING warning
64 E_COMPILE_ERROR fatal compile-time error in the PHP core. This is like an E_ERROR
128 E_COMPILE_WARNING non-fatal compile-time error generated by the Zend Scripting Engine, and an E_WARNING warning
256 E_USER_ERROR fatal user-generated error generated by the Zend Scripting Engine.
512 E_USER_WARNING Non-fatal user-generated warning.
1024 E_USER_NOTICE User generated notifications.
2048 E_STRICT Notification of running time.
4096 E_RECOVERABLE_ERROR Catches fatal errors.
8191 E_ALL for all errors and warnings.
It seems that php does not enable errors by default, so you need to configure the php.ini file:
Change display_errors = Off to display_errors = On
In addition, configure the error level: Change
error_reporting = E_ALL to:
error_reporting = E_ALL & ~E_NOTICE
It should be that php displays all errors by default, and we do not need to display some harmless prompts, so the settings are as above!
can also be used in php code as follows:
The above introduces the usage of the error_reporting function, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.