2022-02-18 PHP 例外処理 PHP try~catch ( 例外処理 ) if ($変数 <= 1) { // 例外を投げる throw new Exception('表示させるエラーメッセージ'); // ExceptionクラスはPHPに組み込まれているためクラス定義が不要 } try { 例外が起きそうな処理; } catch (Exception $e) { echo $e->getMessage(); }