0
基本上,我有一個腳本,使用file_get_contents
進行無限循環,它基本上只是運行該函數,然後增加一個$_GET
變量傳遞給file_get_contents
url,問題顯然是拋出一個錯誤「太多的重定向」,是他們的一種方法,我可以做到這一點的計劃作業或它這樣做沒有錯誤的方式,這是我當前的代碼停止從超時的無限循環
$id = $_GET['id'];
$next_id = $id + 1;
$url = "http://www.website.com/profile/$id.json";
$json = file_get_contents($url);
$result = json_decode($json, true);
$headers = get_headers($url);
if($headers[0] !== "HTTP/1.1 404 Not Found") {
$query = mysql_query("query here");
if($query) {
echo '<script type="text/javascript">
<!-- window.location = "import.php?id='.$next_id.'" //-->
</script>';
} else {
echo '<script type="text/javascript">
<!-- window.location = "import.php?id='.$id.'" //-->
</script>';
}
}
是否有任何其他方法或更有效的方法這樣做?我已經使用這種方法sleep(5)
使用我的重定向嘗試過,但似乎仍然繼續做下去
工作完美,感謝 – 2013-03-16 22:23:43