目录

PHP 异常构造函数

❮ 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 异常参考