Php/ref exception getprevious
来自菜鸟教程
PHP异常getPrevious()方法
例
获取有关先前异常的信息:
<?php
try {
try {
throw new Exception("An
error occurred", 1);
} catch(Exception $e1) {
throw new Exception("Another error occurred", 2, $e1);
}
}
catch (Exception $e2) {
echo $previous = $e2->getPrevious();
echo $previous->getMessage();
}
?>
定义和用法
如果异常是由另一个触发的,则
getPrevious()
方法返回另一个异常。否则,它返回null。
句法
$exception->getPrevious()
技术细节
| 返回值: | 返回一个整数 |
相关页面
在我们的文章中阅读有关异常的更多信息 PHP例外章节
.