Error Levels

Error Levels and error_reporting

Error levels are powers of two that combine as a bitmask: E_WARNING (2), E_NOTICE (8), E_DEPRECATED (8192), the user levels E_USER_WARNING (512), E_USER_NOTICE (1024) and E_USER_DEPRECATED (16384), and the fatal E_ERROR (1), E_PARSE (4) and E_COMPILE_ERROR (64). The error_reporting setting is the mask PHP reports, written with the constants (E_ALL & ~E_DEPRECATED); error_reporting($mask) changes it at run time and returns the old mask.

In PHP 8.5, E_ALL is 30719, not the 32767 older articles quote, because PHP 8.4 removed the E_STRICT level (bit 2048). On this book's Ubuntu 225 server error_reporting() returns 22527, exactly E_ALL & ~E_DEPRECATED: deprecations are hidden. Use E_ALL in development, or you first hear of a deprecation when the feature is removed.

The @ operator masks one expression, so @file_get_contents('/no/such/file') returns false silently, yet error_get_last()['message'] still holds the "Failed to open stream" text. Since PHP 8.0, @ no longer hides fatal errors.