Funkcija restore_exception_handler

Funkcija restore_exception_handler vraća prethodni obrađivač izuzetaka, koji je zamenjen pomoću set_exception_handler. Ova funkcija ne prima parametre i ne vraća vrednost.

Sintaksa

phprestore_exception_handler();

Primer

Postavimo prilagođeni obrađivač izuzetaka, a zatim vratimo prethodni:

php<?php
  function customExceptionHandler($exception) {
    echo 'Custom handler: ' . $exception->getMessage();
  }
  
  set_exception_handler('customExceptionHandler');
  restore_exception_handler();
?>

Primer

Proverimo da posle vraćanja obrađivača radi standardni mehanizam:

php<?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');
?>

Rezultat izvršavanja koda:

php'Handler 1: Test error'