Php/keyword finally
来自菜鸟教程
PHP最终关键字
例
运行一些代码,无论是否引发异常:
<?php
echo "Starting the process.";
try {
// Select
randomly between 0 and 1, throw an exception if 1 is selected.
$random = rand(0, 1);
if($random == 1) {
throw
new Exception("Exception");
}
} finally {
echo "Process
complete";
}
?>
定义和用法
The
finally
关键字用于
try...finally
and
try...catch...finally
无论是否发生异常,都可以运行代码块的结构。
相关页面
The
throw
关键词。
The
catch
关键词。
The
finally
关键词。
在我们的文章中阅读有关异常的更多信息 PHP异常教程
.