Error Levels in PHP

What are the different error levels supported in php?
or
What is the use of error levels?

Explanation

There are error levels in php with the help of which we can specify the type of error messages that should be displayed. Say we want only warning messages or compile errors to be displayed we will use the function error_reporting().
Code Used: e.g:
error_reporting(E_WARNING | E_COMPILE_ERROR);

To use error levels you should know when a type of error will occur. Here we have given the different message types supported by php.
Different Error Types:
NameBit ValueNote
E_ERROR1Fatal Errors that will halt script execution
E_WARNING2Non fatal Runtime Errors.
E_PARSE4Error generated by parser.
E_NOTICE8Run-time notices
E_CORE_ERROR16Error during PHP's initial startup
E_CORE_WARNING32Warning during PHP's initial startup
E_COMPILE_ERROR64Error generated by zend
E_COMPILE_WARNING128Warning generated by zend
E_USER_ERROR256Error generated by user using trigger_error() function
E_USER_WARNING512Warning generated by user using trigger_error() function
E_USER_NOTICE1024Notice generated by user using trigger_error() function
E_ALL2047Defines all messages except E_STRICT
E_STRICT2048

A basic user will not bother too much about error levels as he would use either 0 or E_ALL for error_reporting().
Next >> Error mailing or redirecting error messages to file.

PHP Topics


Ask Questions

Ask Question