PHP Error Levels & Codes

Decode PHP error constants, warning levels and fatal-error codes instantly.

A searchable reference for PHP error level constants (E_ERROR, E_WARNING, E_NOTICE, E_DEPRECATED) with their bitmask values, plus the Throwable and SPL exception class hierarchy. Runs in your browser.

What does error_reporting(E_ALL & ~E_NOTICE) mean?

Error levels are bit flags. E_ALL is a mask of every level, and the & ~E_NOTICE clears the notice bit, so the expression reports all errors and warnings except notices. You can compose any subset with | to include and & ~ to exclude.

This is a searchable reference for PHP’s two error systems — the procedural error level constants (E_ERROR, E_WARNING, E_NOTICE, E_DEPRECATED and friends) and the object-oriented Throwable hierarchy of Error and Exception classes. It pairs each error constant with its bitmask value and each exception class with its parent and typical cause.

How it works

PHP error levels are bit flags: every constant is a distinct power of two (E_ERROR = 1, E_WARNING = 2, E_NOTICE = 8, and so on) and E_ALL is the combined mask. You configure which levels are reported by composing them — | to include a level and & ~ to exclude one. For example E_ALL & ~E_DEPRECATED reports everything except deprecation notices.

Separately, since PHP 7 the engine throws objects for many failures. The root is the Throwable interface, which splits into Error (engine and type problems like TypeError, DivisionByZeroError) and Exception (user-land errors, including the SPL classes LogicException and RuntimeException). Catching \Throwable handles both branches; catching \Exception alone misses the Error family.

Example

A reporting mask plus catching the modern Throwable tree:

error_reporting(E_ALL & ~E_NOTICE);     // everything except notices

try {
    $r = intdiv(10, 0);                  // throws DivisionByZeroError (an Error)
} catch (\Throwable $e) {                // catches Error AND Exception
    echo get_class($e) . ": " . $e->getMessage();
}

Note that DivisionByZeroError extends ArithmeticError, which extends Error, which implements Throwable — so a plain catch (\Exception $e) would not catch it, but catch (\Throwable $e) does. Everything runs in your browser; nothing is uploaded.