Funktsioon restore_exception_handler

Funktsioon restore_exception_handler taastab eelneva erindite töötleja, mis on asendatud funktsiooni set_exception_handler abil. See funktsioon ei võta parameetreid ega tagasta väärtusi.

Süntaks

phprestore_exception_handler();

Näide

Seadistame kohandatud erindite töötleja ja seejärel taastame eelneva:

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

Näide

Kontrollime, et pärast töötleja taastamist töötab standardne mehhanism:

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

Koodi täitmise tulemus:

php'Handler 1: Test error'