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'