Fonksiyon restore_exception_handler

restore_exception_handler fonksiyonu, set_exception_handler ile değiştirilmiş olan önceki istisna işleyicisini geri yükler. Bu fonksiyon parametre almaz ve değer döndürmez.

Sözdizimi

phprestore_exception_handler();

Örnek

Bir özel istisna işleyici ayarlayalım ve ardından öncekini geri yükleyelim:

php<?php
  function customExceptionHandler($exception) {
    echo 'Özel işleyici: ' . $exception->getMessage();
  }
  
  set_exception_handler('customExceptionHandler');
  restore_exception_handler();
?>

Örnek

Geri yüklemeden sonra standart mekanizmanın çalıştığını kontrol edelim:

php<?php
  set_exception_handler(function($exception) {
    echo 'İşleyici 1: ' . $exception->getMessage();
  });
  
  set_exception_handler(function($exception) {
    echo 'İşleyici 2: ' . $exception->getMessage();
  });
  
  restore_exception_handler();
  throw new Exception('Test hatası');
?>

Kodun çalıştırılmasının sonucu:

php'İşleyici 1: Test hatası'