2

以下に正常に動作する PHP ループがありますが、CURL 要求によってエラー ページが返されることがあります。ループ全体を再起動せずに、その現在のページの操作のみを再起動するにはどうすればよいですか?

while ($daytofetch <= $lastdaytofetch) {

//Do all my stuff and run curl request here 

$daytofetch++

}
4

2 に答える 2

2

私はおそらく次のようなことをするでしょう:

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++
}
于 2013-01-15T21:24:02.303 に答える
2
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++
}
于 2013-01-15T21:24:26.723 に答える