Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

restore_exception_handler()

Example

Example of how to restore the exception handler:

<?php
// Two user-defined exception handler functions
function myException1($exception) {
    echo “[“ . __FUNCTION__ . “]” . $exception->getMessage();
}
function myException2($exception) {
    echo “[“ . __FUNCTION__ . “]” . $exception->getMessage();
}

set_exception_handler(“myException1”);
set_exception_handler(“myException2”);

restore_exception_handler();

// Throw exception
throw new Exception(“This triggers the first exception handler…”);
?>

Definition and Usage

The restore_exception_handler() function reverts to the previous exception handler.

It is used to restore the exception handler that was in place before it was changed using the set_exception_handler() function.

 

Tip: The previous exception handler may be either the built-in exception handler or a user-defined exception handler function.

Syntax

restore_exception_handler();

Technical Details

Return Value:

Always returns TRUE.

PHP Version:

5.0+