The function sets the error_reportingerror_reporting() directive at run time. PHP has several levels of errors to notify, using this function defines the duration level (execution time) of your scripts. If the optional level parameter is not defined, the function will only return the current level of error notification.error_reporting()
Parameters
level
The new level of error_reporting . This level takes a bitmask or named constants. When using named constants it is strongly recommended to ensure compatibility for future versions. As error levels are added, the range of integers increases, so old integer-based error levels will not always behave as expected.
The available error level constants, and the actual meanings of those error levels, are described in predefined constants .
Return Values
Returns the old level of error_reporting or the current level if the level parameter is not supplied.
Example
<?php
// Desactivar toda notificación de error
error_reporting(0);
// Notificar solamente errores de ejecución
error_reporting(E_ERROR | E_WARNING | E_PARSE);
// Notificar E_NOTICE también puede ser bueno (para informar de variables
// no inicializadas o capturar errores en nombres de variables ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
// Notificar todos los errores excepto E_NOTICE
error_reporting(E_ALL ^ E_NOTICE);
// Notificar todos los errores de PHP (ver el registro de cambios)
error_reporting(E_ALL);
// Notificar todos los errores de PHP
error_reporting(-1);
// Lo mismo que error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
?>
error_reporting
The function sets the error_reporting
error_reporting()
directive at run time. PHP has several levels of errors to notify, using this function defines the duration level (execution time) of your scripts. If the optional level parameter is not defined, the function will only return the current level of error notification.error_reporting()
Parameters
level
The new level of error_reporting . This level takes a bitmask or named constants. When using named constants it is strongly recommended to ensure compatibility for future versions. As error levels are added, the range of integers increases, so old integer-based error levels will not always behave as expected.
The available error level constants, and the actual meanings of those error levels, are described in predefined constants .
Return Values
Returns the old level of error_reporting or the current level if the level parameter is not supplied.
Example