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. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

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.

PHP’s two parallel error systems

PHP grew its error system in two separate eras, and both are still active today:

Procedural error levels predate PHP 5. They are integer bitmasks set via error_reporting() and handled by a global handler registered with set_error_handler(). You cannot catch them with try/catch.

Object exceptions arrived with PHP 5 and were significantly expanded in PHP 7. They are objects you throw and catch in the normal way. Since PHP 7, the Throwable interface is the common ancestor of both Error (engine errors, type failures, division by zero) and Exception (user-land application errors). Code written before PHP 7 that catches \Exception will silently miss the \Error family — a common source of uncaught fatal errors after an upgrade.

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.

The full bitmask table includes these key values:

ConstantValueSeverity
E_ERROR1Fatal — script stops
E_WARNING2Non-fatal, logged
E_PARSE4Parse error
E_NOTICE8Minor issue
E_DEPRECATED8192Feature will be removed
E_ALL32767Every level

Code 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();
}

DivisionByZeroError extends ArithmeticError, which extends Error, which implements Throwable — so a plain catch (\Exception $e) would not catch it, but catch (\Throwable $e) does.

The Throwable hierarchy at a glance

Throwable
├── Error
│   ├── TypeError
│   ├── ParseError
│   ├── ArithmeticError
│   │   └── DivisionByZeroError
│   └── AssertionError
└── Exception
    ├── RuntimeException
    │   ├── OutOfBoundsException
    │   └── UnexpectedValueException
    └── LogicException
        ├── InvalidArgumentException
        └── BadMethodCallException

Common mistakes

  • Catching only \Exception after a PHP 7 upgrade: the \Error family slips through uncaught.
  • Using E_ALL in production without suppressing E_NOTICE and E_STRICT: trivial notices fill logs and hide real errors.
  • Confusing E_RECOVERABLE_ERROR (can be caught by a custom error handler) with a true fatal E_ERROR (cannot).

Everything runs in your browser; nothing is uploaded.