restore_error_handler — 還原之前的錯誤處理函數
說明
bool restore_error_handler ( void )
在使用 set_error_handler() 改變錯誤處理函數之後,此函數可以 用於還原之前的錯誤處理程式(可以是內建的或者也可以是使用者所定義的函數)。
傳回值
該函數總是返回 TRUE 。
restore_error_handler() 執行個體
如果是 unserialize() 導致了一個錯誤,接下來 會恢複原來的錯誤處理函數。
<?phpfunction unserialize_handler ( $errno , $errstr ){ echo "Invalid serialized value.\n" ;}$serialized = 'foo' ;set_error_handler ( 'unserialize_handler' );$original = unserialize ( $serialized );restore_error_handler ();?>
以上常式會輸出:
Invalid serialized value.
restore_exception_handler — 恢複之前定義過的異常處理函數。
說明
bool restore_exception_handler ( void )
在使用 set_exception_handler() 改變異常處理函數之後,此函數可以 用於還原之前的例外處理常式(可以是內建的或者也可以是使用者所定義的函數)。
傳回值
該函數總是返回 TRUE 。
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...