try
{
//
}
catch( Exception $e )
{
//
}
例外を捕捉しないと、Fatal error: Uncaught exception 'Exception' with message '...'として、致命的なエラーとなります。
捕捉されない例外が発生したときに、独自の関数でそれを処理できます。
callable set_exception_handler( callable $exception_handler )PHP: set_exception_handler - Manual
try
{
throw new Exception( '...' );
}
catch( Exception $e )
{
echo $e->getMessage();
}
Exceptionクラスには、
の4つのprotectedなプロパティがあり、それぞれ
のメソッドから取得できます。