【发布时间】:2011-01-19 02:49:48
【问题描述】:
<?php
function some_function($arg) {
if($filter->check_for_safe_input($arg)) {
throw new Exception("Hacking Attempt");
}
do_some_database_stuff($arg);
}
?>
在上面的代码示例中,如果check_for_safe_input 失败,是否会调用do_some_database_stuff,或者异常是否会停止函数运行?这是我一直不太确定的事情,通常我只是将 do_some_database_stuff 之类的函数粘贴在 else 语句中以确保,但这往往会导致大量嵌套的函数。
【问题讨论】: