Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

error_reporting()

Example

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);
?>

Definition and Usage

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.

Syntax

error_reporting(level);

Parameter Values

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.

Technical Details

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.