PHP try-catch 不起作用
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';
}
但是,它不只是要捕获部分并返回,而是在以 开头的行中显示警告。我从来没有想过在php中使用异常,但在C#中经常使用它们,似乎在PHP中它们的工作方式不同,或者像往常一样,我错过了一些明显的东西。nothing
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given
while