php restore_error_handler()函數與restore_exception_handler()函數

來源:互聯網
上載者:User
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...

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.