Set different levels of error reporting.
<?php // Turn off error reporting error_reporting(0); // Report runtime errors error_reporting(E_ERROR | E_WARNING | E_PARSE); // Report all errors error_reporting(E_ALL); // Same as error_reporting(E_ALL); ini_set(“error_reporting”, E_ALL); // Report all errors except E_NOTICE error_reporting(E_ALL & ~E_NOTICE); ?> |
The error_reporting() function determines which errors are reported.
\PHP supports various error levels, and this function sets the reporting level for the current script.
error_reporting(level); |
Parameter |
Description |
level |
Optional. Sets the error reporting level for the current script. You can use error numbers or named constants. Note: Using named constants is recommended for better compatibility with future PHP versions. |
Return Value: |
Returns the previous error reporting level, or the current error reporting level if no level parameter is provided. |
PHP Version: |
4.0+ |
PHP Changelog: |
PHP 5.4: E_STRICT is now included in E_ALL. PHP 5.3: Introduced E_DEPRECATED and E_USER_DEPRECATED. PHP 5.2: Added E_RECOVERABLE_ERROR. PHP 5.0: Introduced E_STRICT. |