恢復之前定義過的異常處理函式。

restore_exception_handler

(PHP 5, PHP 7, PHP 8)

restore_exception_handler 恢復之前定義過的異常處理函式。

說明

restore_exception_handler(): bool

在使用 set_exception_handler() 改變異常處理函式之後,此函式可以 用於還原之前的異常處理程式(可以是內建的或者也可以是使用者所定義的函式)。

返回值

該函式總是返回 true

範例

示例 #1 restore_exception_handler() 範例

<?php
    
function exception_handler_1(Exception $e)
    {
        echo 
'[' __FUNCTION__ '] ' $e->getMessage();
    }

    function 
exception_handler_2(Exception $e)
    {
        echo 
'[' __FUNCTION__ '] ' $e->getMessage();
    }

    
set_exception_handler('exception_handler_1');
    
set_exception_handler('exception_handler_2');

    
restore_exception_handler();

    throw new 
Exception('This triggers the first exception handler...');
?>

以上例程會輸出:

[exception_handler_1] This triggers the first exception handler...

參見

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *