我在下面有一个 PHP 循环,它可以正常工作,但是有时 CURL 请求会返回一个错误页面,我怎样才能只重新启动当前页面的操作而不重新启动整个循环?
while ($daytofetch <= $lastdaytofetch) {
//Do all my stuff and run curl request here
$daytofetch++
}
我在下面有一个 PHP 循环,它可以正常工作,但是有时 CURL 请求会返回一个错误页面,我怎样才能只重新启动当前页面的操作而不重新启动整个循环?
while ($daytofetch <= $lastdaytofetch) {
//Do all my stuff and run curl request here
$daytofetch++
}
我可能会做这样的事情:
while ($daytofetch <= $lastdaytofetch) {
$error = false;
//Do all my stuff and run curl request here
//if there is an error, then set $error = true;
if (!$error)
$daytofetch++
}
while ($daytofetch <= $lastdaytofetch) {
// Do all my stuff and run curl request here
if ($error_detected) {
// This will resume the loop without incrementing
// $daystofetch
continue;
}
$daytofetch++
}