Funkcija restore_exception_handler
Funkcija restore_exception_handler atkuria ankstesnį išimčių tvarkytuvą,
kuris buvo pakeistas naudojant set_exception_handler. Ši funkcija nepriima parametrų
ir negrąžina jokių reikšmių.
Sintaksė
restore_exception_handler();
Pavyzdys
Nustatykime pasirinktinį išimčių tvarkytuvą, o tada atkurkime ankstesnį:
<?php
function customExceptionHandler($exception) {
echo 'Custom handler: ' . $exception->getMessage();
}
set_exception_handler('customExceptionHandler');
restore_exception_handler();
?>
Pavyzdys
Patikrinkime, kad po tvarkytuvo atkūrimo veikia standartinis mechanizmas:
<?php
set_exception_handler(function($exception) {
echo 'Handler 1: ' . $exception->getMessage();
});
set_exception_handler(function($exception) {
echo 'Handler 2: ' . $exception->getMessage();
});
restore_exception_handler();
throw new Exception('Test error');
?>
Kodo vykdymo rezultatas:
'Handler 1: Test error'