在PHP中中断当前循环迭代并继续循环
从数据库检索数据在PHP中中断当前循环迭代并继续循环,php,while-loop,Php,While Loop,从数据库检索数据 while($row_posts = mysql_fetch_array($run_posts)) { $post_id1=$row_posts['userID']; $post_title=$row_posts['torrent_hash']; try{ $transmission = new Transmission\Transmission(); $torrent = $transmission->get($post_tit
while($row_posts = mysql_fetch_array($run_posts))
{
$post_id1=$row_posts['userID'];
$post_title=$row_posts['torrent_hash'];
try{
$transmission = new Transmission\Transmission();
$torrent = $transmission->get($post_title);
$torrent->getName();
}
catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
使用传输软件检查哈希值
while($row_posts = mysql_fetch_array($run_posts))
{
$post_id1=$row_posts['userID'];
$post_title=$row_posts['torrent_hash'];
try{
$transmission = new Transmission\Transmission();
$torrent = $transmission->get($post_title);
$torrent->getName();
}
catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
如果在传输中未找到散列id,则显示如下错误
Caught exception: Torrent with ID 58bd21a7938cb1d65f737bcb6031111816d924d9 not found
Notice: Undefined variable: torrent in C:\xampp\htdocs\final\info.php on line 46
Fatal error: Call to a member function isFinished() on a non-object in C:\xampp\htdocs\final\info.php on line 46
我需要输出,比如如果发生运行时异常,那么只需中断第一个循环并从数据库执行第二个值即可?Try command
continue
continue在循环结构中用于跳过当前循环迭代的其余部分,并在条件评估时继续执行,然后开始下一个迭代
看