PHP例外コンストラクタ
例
<?php
...
throw new Exception("Division by zero", 1);
...
?>
定義と使用法
コンストラクターは、Exception()
Exceptionオブジェクトを作成し、そのプロパティの一部を設定するために使用されます。
構文
new Exception(message, code, previous)
パラメータ値
Parameter | Description |
---|---|
message | Optional. A string describing why the exception was thrown |
code | Optional. An integer that can be used used to easily distinguish this exception from others of the same type |
previous | Optional. If this exception was thrown in a catch block of another exception, it is recommended to pass that exception into this parameter |
関連ページ
例外の詳細については、PHPの例外の章をご覧ください。
❮PHP例外リファレンス