Funzione restore_exception_handler
La funzione restore_exception_handler ripristina il gestore delle eccezioni precedente,
che è stato sostituito tramite set_exception_handler. Questa funzione non accetta parametri
e non restituisce valori.
Sintassi
restore_exception_handler();
Esempio
Impostiamo un gestore di eccezioni personalizzato e poi ripristiniamo quello precedente:
<?php
function customExceptionHandler($exception) {
echo 'Gestore personalizzato: ' . $exception->getMessage();
}
set_exception_handler('customExceptionHandler');
restore_exception_handler();
?>
Esempio
Verifichiamo che dopo il ripristino del gestore funzioni il meccanismo standard:
<?php
set_exception_handler(function($exception) {
echo 'Gestore 1: ' . $exception->getMessage();
});
set_exception_handler(function($exception) {
echo 'Gestore 2: ' . $exception->getMessage();
});
restore_exception_handler();
throw new Exception('Errore di test');
?>
Risultato dell'esecuzione del codice:
'Gestore 1: Errore di test'