【发布时间】:2012-09-04 20:32:19
【问题描述】:
try
{
$matrix = Query::take("SELECT moo"); //this makes 0 sense
while($row = mysqli_fetch_array($matrix, MYSQL_BOTH)) //and thus this line should be an error
{
}
return 'something';
}
catch(Exception $e)
{
return 'nothing';
}
但是,它不是仅仅捕获部分并返回nothing,而是在以while 开头的行中显示警告Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given。我从来没有想过在 php 中使用异常,但在 C# 中经常使用它们,而且在 PHP 中它们的工作方式似乎不同,或者像往常一样,我遗漏了一些明显的东西。
【问题讨论】:
-
@SirDarius - 有趣且值得阅读的链接。谢谢:)