array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'function.set-exception-handler.php', 1 => 'set_exception_handler', ), 'up' => array ( 0 => 'ref.errorfunc.php', 1 => 'エラー処理関数', ), 'prev' => array ( 0 => 'function.set-error-handler.php', 1 => 'set_error_handler', ), 'next' => array ( 0 => 'function.trigger-error.php', 1 => 'trigger_error', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'ja', 'path' => 'reference/errorfunc/functions/set-exception-handler.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5, PHP 7, PHP 8)
set_exception_handler — ユーザー定義の例外ハンドラ関数を設定する
例外が try/catch ブロックの中でキャッチされなかった場合の
デフォルトの例外ハンドラを設定します。
実行は、callback
がコールされた後に
停止します。
例1 set_exception_handler() の例
<?php
function exception_handler(Throwable $exception) {
echo "Uncaught exception: " , $exception->getMessage(), "\n";
}
set_exception_handler('exception_handler');
throw new Exception('Uncaught Exception');
echo "Not Executed\n";
?>