以下に正常に動作する 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++
}