我编写了一个脚本来对一些点进行地理编码,这些点的结构基本上是这样的:
//get an unupdated record
$arr_record;
while(count($arr_record) > 0)
{
//strings are derived from $arr_record
geocode($string1);
geocode($string2);
geocode($string3);
array_pop($arr_record);
}
function geocode($string) {
//if successful
update($coords)
}
function update($coords) {
//update the database
header('Location:http://localhost/thisfile.php')
}
问题在于,即使地理编码成功并且数据库已更新,并且重新发送了标头,脚本仍会返回到 while 循环,而无需重新加载页面并重新开始新记录。
这是 PHP 的正常行为吗?我如何避免它表现得像这样?