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