PHP restore_exception_handler() 関数

例外処理プログラムの復元:

<?php
// 2つのユーザー定義の例外処理関数
 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 new Exception("これは最初の例外処理関数をトリガーします...");
 ?> 

上記のコードの出力は以下のようになります:

[myException1] これは最初の例外処理関数をトリガーします...

定義と使用方法

restore_exception_handler() 関数は前の例外処理プログラムを復元します。

set_exception_handler() を使用して例外処理関数を変更した後、この関数は前の例外処理プログラムを元に戻すために使用できます。

ヒント:前の例外処理関数は、組み込みのものまたはユーザーが定義した関数でできます。

文法

restore_exception_handler();

技術的詳細

返り値: 常に TRUE を返します。
PHP バージョン: 5.0+