PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

restore_exception_handler> <error_reporting
Last updated: Fri, 11 Apr 2008

view this page in

restore_error_handler

(PHP 4 >= 4.0.1, PHP 5)

restore_error_handler — Recupera la función de gestión de errores previa

Descripción

bool restore_error_handler ( void )

Usada después de modificar la función de gestión de errores usando set_error_handler(), para revertir al gestor de errores previo (el cual puede ser el incorporado o una función definida por el usuario).

Valores retornados

Esta función siempre devuelve TRUE.

Ejemplos

Example #1 Ejemplo de restore_error_handler()

Decidir si unserialize() causó un error, entonces recuperar el gestor de errores original.

<?php
function gestor_unserialize($errno$errstr)
{
    echo 
"Valor seriado inválido.\n";
}

$seriado 'foo';
set_error_handler('gestor_unserialize');
$original unserialize($seriado);
restore_error_handler();
?>

El resultado del ejemplo seria:

Valor seriado inválido.

Notes

Note: Llamar restore_error_handler() desde la función error_handler es ignorado.



add a note add a note User Contributed Notes
restore_error_handler
edgarinvillegas at hotmail dot com
28-Mar-2008 05:21
Isolde is kind of wrong. The error handlers are stacked with set_error_handler(), and popped with restore_error_handler(). Here i put an example:

<?php
    mysql_connect
("inexistent"); //Generate an error. The actual error handler is set by default

   
function foo1() {echo "<br>Error foo1<br>";}
    function
foo2() {echo "<br>Error foo2<br>";}
    function
foo3() {echo "<br>Error foo3<br>";}
   
   
set_error_handler("foo1");    //current error handler: foo1
   
set_error_handler("foo2");    //current error handler: foo2
   
set_error_handler("foo3");    //current error handler: foo3
   
   
mysql_connect("inexistent");   
   
restore_error_handler();        //now, current error handler: foo2
   
mysql_connect("inexistent");    
   
restore_error_handler();        //now, current error handler: foo1
   
mysql_connect("inexistent");
   
restore_error_handler();        //now current error handler: default handler
   
mysql_connect("inexistent");
   
restore_error_handler();        //now current error handler: default handler (The stack can't pop more)
?>
lsole at maresme dot net
14-Mar-2004 08:57
As the docs say, restore_error_handler() revert to the *previous error handler*... even if it is the same. A bug made me set twice my custom error handler and later when I was calling restore_error_handler() to restore the built-in handler nothing seemed to happen... this puzzled me for a while!

restore_exception_handler> <error_reporting
Last updated: Fri, 11 Apr 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites