Php/ref exception getcode
来自菜鸟教程
引发异常并输出其代码:
<?php
try {
throw new Exception("An error occurred", 120);
}
catch(Exception $e) {
echo "Error code: " . $e->getCode();
}
?>
The
getCode()
方法返回一个整数,该整数可用于标识异常。
$exception->getCode()
| 返回值: | 返回一个整数 |
在我们的文章中阅读有关异常的更多信息 PHP例外章节
.