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 Values

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 Changelog: PHP 5.4: E_STRICT is now a part of E_ALL.
PHP 5.3: New: E_DEPRECATED and E_USER_DEPRECATED.
PHP 5.2: New: E_RECOVERABLE_ERROR.
PHP 5.0: New: E_STRICT.

PHP Error Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.