The error_reporting Function

The error_reporting function sets the level of errors that will be displayed during script execution. It can accept either predefined error level constants or their combination using bitwise OR. The function returns the previous reporting level.

Syntax

phperror_reporting([int $level]);

Example

Set the reporting level to display all errors:

php<?php
  error_reporting(E_ALL);
?>

Example

Disable error reporting:

php<?php
  error_reporting(0);
?>

Example

Set a combined reporting level:

php<?php
  error_reporting(E_ERROR | E_WARNING | E_PARSE);
?>

Example

Get the current reporting level:

php<?php
  $current_level = error_reporting();
  echo $current_level;
?>

See Also

  • the ini_set function,
    which sets configuration settings
  • the set_error_handler function,
    which sets a custom error handler