En principio, al poner E_ALL ^ E_NOTICE con la función error_reporting no debería reportar los NOTICES pero sí lo hace. Tambien he probado con E_ALL & ~E_NOTICE.
¿Alguien se le ocurre por qué me llegan los E_NOTICE?
Código PHP:
// establecemos qué errores seran reportados
error_reporting(E_ALL ^ E_NOTICE);
// establecemos la funcion que tratará los errores
set_error_handler( 'errorHandler' );
// funcion que trata los errores
function errorHandler( $errno, $errstr, $errfile, $errline, $errcontext )
{
// error types
$errortype = array (
E_ERROR => 'Error',
E_WARNING => 'Warning',
E_PARSE => 'Parsing Error',
E_NOTICE => 'Notice',
E_CORE_ERROR => 'Core Error',
E_CORE_WARNING => 'Core Warning',
E_COMPILE_ERROR => 'Compile Error',
E_COMPILE_WARNING => 'Compile Warning',
E_USER_ERROR => 'User Error',
E_USER_WARNING => 'User Warning',
E_USER_NOTICE => 'User Notice',
E_STRICT => 'Runtime Notice',
E_RECOVERABLE_ERROR => 'Catchable Fatal Error'
);
// error threshold
$threshold = array(
1 => E_USER_ERROR ,
2 => E_USER_WARNING | E_USER_ERROR ,
3 => E_ALL
);
// save message into log
if( CFG_ERROR_LOG_REGISTER
&& ($threshold[CFG_ERROR_LOG_THRESHOLD] & $errno) == $errno )
{
// create error message
$error_msg = "[".date("d-m-Y H:i:s")."] - ".$errortype[$errno]." - $errfile, line $errline";
$error_msg .= "\n$errstr";
if( isset($errcontext['this']) )
{
if( is_object($errcontext['this']) )
{
$classname = get_class($errcontext['this']);
$parentclass = get_parent_class($errcontext['this']);
$error_msg .= "\nObject/Class: '$classname', Parent Class: '$parentclass'";
}
}
$error_msg .= "\n\n";
$fichero = FICHERO_REGISTRO_ERRORES;
// guardamos el mensaje en el fichero
file_put_contents($fichero, $error_msg, FILE_APPEND);
}
} // end function errorHandler
La constante CFG_ERROR_LOG_THRESHOLD está en 3. Es decir, guardar todos los errores que le lleguen.
La constante CFG_ERROR_LOG_REGISTER es un flag para activar o desactivar el registro de errores en fichero.