restore_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...");
?>
上のコードの出力は、次の通り:
[myException1] This triggers the first exception handler...
restore_exception_handler() 関数は、前の例外ハンドラを回復します。
この関数は、set_exception_handler()関数で変更した後に、 前の例外ハンドラを回復するために使用します。
チップ: 前の例外ハンドラは、組み込みの例外ハンドラまたはユーザ定義の例外ハンドラ関数です。
restore_exception_handler();
技術内容/h2>
返り値: | 常に TRUE を返します |
---|---|
PHP バージョン: | 5.0+ |