restore_exception_handler funksiyası
restore_exception_handler funksiyası, set_exception_handler vasitəsi ilə əvəz edilmiş əvvəlki istisna emaledicisini bərpa edir.
Bu funksiya parametr qəbul etmir və heç bir dəyər qaytarmır.
Sintaksis
restore_exception_handler();
Nümunə
Gəlin fərdi istisna emaledicisi təyin edək, sonra isə əvvəlkini bərpa edək:
<?php
function customExceptionHandler($exception) {
echo 'Custom handler: ' . $exception->getMessage();
}
set_exception_handler('customExceptionHandler');
restore_exception_handler();
?>
Nümunə
Bərpadan sonra standart mexanizmin işlədiyini yoxlayaq:
<?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');
?>
Kodun icra nəticəsi:
'Handler 1: Test error'