error_reporting

FunctionParams and return types changed in PHP 8.0

Sets which PHP errors are reported.

PHP 5
PHP 7
PHP 8.0
Improved
PHP 8.1
PHP 8.2
PHP 8.3
PHP 8.4
PHP 8.5

error_reporting Function synopsis

error_reporting(?int $error_level = null): int

Parameters

$error_level

OptionalType?intDefault valuenull

The new error_reporting level. It takes on either a bitmask, or named constants. Using named constants is strongly encouraged to ensure compatibility for future versions. As error levels are added, the range of integers increases, so older integer-based error levels will not always behave as expected.

$error_level accepts one or a bitmask of the following constant values:

Return value

Typeint

Returns the error_reporting level, before it is changed to $error_level.

error_reporting returns one or a bitmask of the following constant values:

Changes to the error_reporting Function

PHP 8.0

  • Return type added: int
  • Parameter name of parameter #1 changed: $new_error_level to $error_level
  • Parameter type added for parameter #1 ($error_level): ?int
  • Parameter default value added for position #1 ($error_level): null
- error_reporting($new_error_level)
+ error_reporting(?int $error_level = null): int

error_reporting Function Availability

PHP VersionAvailability
PHP 8.5Future Release Yes
PHP 8.4Upcoming Release Yes
PHP 8.3Supported (Latest) Yes
PHP 8.2Supported Yes
PHP 8.1Security-Fixes Only Yes
PHP 8.0Unsupported Yes
PHP 7.4Unsupported Yes
PHP 7.3Unsupported Yes
PHP 7.2Unsupported Yes
PHP 7.1Unsupported Yes
PHP 7.0Unsupported Yes
PHP 5.6Unsupported Yes
PHP 5.5Unsupported Yes
PHP 5.4Unsupported Yes
PHP 5.3Unsupported Yes