phpでexception_handler設定

phpにてexception_handlerを使用した時のメモ

exception_handlerは*catchされなかった例外*に対して処理を指定できる。
try {} catch () {}された場合はcatch内の処理が実行。
マニュアル->http://php.net/manual/ja/function.set-exception-handler.php

*php-version:5.1.6*
[exception.php]

<?php
    /**
     *  ExceptionHandler処理
    **/
    function exception_handler(Exception $e) {
        $class_name = get_class($e);
        switch ($class_name) {
        case 'Exception':
            print "Exception_error\n";
            break;
        default:
            print "error\n";
            break;
        }
    }

    // exception_handlerをセット
    set_exception_handler('exception_handler');

    // 例外をthrow(try{}catch{}を動かす場合はコメントアウト)
    // exception_handerが実行される
    throw new exception();

    // 例外をthrow(catch含む)
    try {
        // catch内処理が実行される
        throw new exception();
    } catch (Exception $e) {
        print "catch_Exception_error";
    }
?>

uncatchExceptionの発生時にコールされる。