THE WORLD'S LARGEST WEB DEVELOPER SITE

PHP error_reporting() Function

PHP Error Reference

Example

Specify different error level 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);
?>


Definition and Usage

The error_reporting() function specifies which errors are reported.

PHP has many levels of errors, and using this function sets that level for the current script.


Syntax

error_reporting(level);

Parameter Description
level Optional. Specifies the error-report level for the current script. Error numbers and named constants are accepted. Note: Named constants are recommended to ensure compatibility for future PHP versions

Technical Details

Return Value: Returns the old error reporting level or the current error reporting level if no level parameter is given
PHP Version: 4.0+

PHP Error Reference