Predefined Constants

The constants below are always available as part of the PHP core.

The following constants (either the corresponding numerical value or their symbolic name) are used as a bitmask to specify which errors to report. It is possible to use bitwise operators to combine these values or mask out certain types of errors.

Tip

The name of the constants can be used within php.ini, instead of the raw numerical values to which they correspond to. However, only the |, ~, ^, !, & operators are understood within php.ini.

Warning

It is not possible to use the symbolic names outside of PHP. For example in httpd.conf the computed bitmask value must be used instead.

E_ERROR (int)
Fatal run-time errors. These indicate errors that can not be recovered from, such as a memory allocation problem. Execution of the script is halted. Value of the constant: 1
E_WARNING (int)
Run-time warnings (non-fatal errors). Execution of the script is not halted. Value of the constant: 2
E_PARSE (int)
Compile-time parse errors. Parse errors should only be generated by the parser. Value of the constant: 4
E_NOTICE (int)
Run-time notices. Indicate that the script encountered something that could indicate an error, but could also happen in the normal course of running a script. Value of the constant: 8
E_CORE_ERROR (int)
Fatal errors that occur during PHP's initial startup. This is like an E_ERROR, except it is generated by the core of PHP. Value of the constant: 16
E_CORE_WARNING (int)
Warnings (non-fatal errors) that occur during PHP's initial startup. This is like an E_WARNING, except it is generated by the core of PHP. Value of the constant: 32
E_COMPILE_ERROR (int)
Fatal compile-time errors. This is like an E_ERROR, except it is generated by the Zend Scripting Engine. Value of the constant: 64
E_COMPILE_WARNING (int)
Compile-time warnings (non-fatal errors). This is like an E_WARNING, except it is generated by the Zend Scripting Engine. Value of the constant: 128
E_DEPRECATED (int)
Run-time deprecation notices. Enable this to receive warnings about code that will not work in future versions. Value of the constant: 8192
E_USER_ERROR (int)
User-generated error message. This is like an E_ERROR, except it is generated in PHP code by using the PHP function trigger_error. Value of the constant: 256
Warning

Usage of this constant with trigger_error is deprecated as of PHP 8.4.0. It is recommended to either throw an Exception or call exit instead.

E_USER_WARNING (int)
User-generated warning message. This is like an E_WARNING, except it is generated in PHP code by using the PHP function trigger_error. Value of the constant: 512
E_USER_NOTICE (int)
User-generated notice message. This is like an E_NOTICE, except it is generated in PHP code by using the PHP function trigger_error. Value of the constant: 1024
E_USER_DEPRECATED (int)
User-generated deprecation message. This is like an E_DEPRECATED, except it is generated in PHP code by using the PHP function trigger_error. Value of the constant: 16384
E_STRICT (int)
Run-time suggestions emitted by PHP about the executed code to ensure forward compatibility. Value of the constant: 2048
Warning

This error level is unused, and has been deprecated as of PHP 8.4.0.

E_RECOVERABLE_ERROR (int)
Legacy engine "exceptions" which correspond to catchable fatal error. Similar to Error but must be caught via a user defined error handler (see set_error_handler). If not handled, this behaves like E_ERROR. Value of the constant: 4096

Note: This error level is effectively unused, the only case where this can happen is when interpreting an object as a bool fails. This can only happen for internal objects. The most common example, prior to PHP 8.4.0, is using a GMP instance in a conditional.

E_ALL (int)
Bit-mask that contains every single error, warning, and notice. Value of the constant: 32767