set_exception_handler
ユーザー定義の例外ハンドラ関数を設定する
&reftitle.description;
callablenullset_exception_handler
callablenullcallback
例外が try/catch ブロックの中でキャッチされなかった場合の
デフォルトの例外ハンドラを設定します。
実行は、callback がコールされた後に
停止します。
&reftitle.parameters;
callback
キャッチされない例外が発生した際にコールされる関数。
このハンドラ関数は、スローされる
Throwable オブジェクトを引数にとります。
Error と
Exception は、
どちらも Throwable
インターフェイスを実装しています。
ハンドラのシグネチャは、次のようになります。
voidhandler
Throwableex
&null; を渡すと、このハンドラをデフォルトの状態に戻せます。
&reftitle.returnvalues;
前に定義された例外ハンドラを返します。
エラー発生時に &null; を返します。
前にハンドラが定義されていない場合にも &null; が返されます。
&reftitle.examples;
set_exception_handler の例
getMessage(), "\n";
}
set_exception_handler('exception_handler');
throw new Exception('Uncaught Exception');
echo "Not Executed\n";
?>
]]>
&reftitle.seealso;
restore_exception_handler
restore_error_handler
error_reporting
例外(exceptions)