ფუნქცია restore_exception_handler

ფუნქცია restore_exception_handler აღადგენს წინა გამონაკლისების დამმუშავებელს, რომელიც შეიცვალა set_exception_handler-ის საშუალებით. ეს ფუნქცია არ იღებს პარამეტრებს და არ აბრუნებს მნიშვნელობებს.

სინტაქსი

phprestore_exception_handler();

მაგალითი

მოდით დავაყენოთ მომხმარებლის გამონაკლისების დამმუშავებელი, შემდეგ კი აღვადგინოთ წინა:

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

მაგალითი

შევამოწმოთ, რომ დამმუშავებლის აღდგენის შემდეგ მუშაობს სტანდარტული მექანიზმი:

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

კოდის შესრულების შედეგი:

php'Handler 1: Test error'