error_reporting
Sets which errors PHP should report.
Syntax
error_reporting(?int $error_level = null): intParameters
| Parameter | Type | Description |
|---|---|---|
| $error_level | ?int | Optional. A set of `E_…` constants. |
Return value
intThe previous level.
Examples
All errors, and all except deprecations:
<?php
error_reporting(E_ALL);
var_dump(error_reporting() === E_ALL);
error_reporting(E_ALL & ~E_DEPRECATED);
var_dump((error_reporting() & E_DEPRECATED) === 0);Output:
bool(true)
bool(true)Notes
During development turn on E_ALL. On a production server errors are not hidden but stop being displayed: display_errors = 0, log_errors = 1.
See also
- ini_set — Changes a PHP setting for the duration of the program.
- set_error_handler — Sets a custom function to handle PHP warnings and notices.
- error_log — Writes a message to the error log.
In the tutorial
- Errors and debugging — The kinds of PHP errors, error display settings, the log, turning warnings into exceptions and debugging techniques.