我有这个PHP代码:
<?php
if(isset($_POST['gen'])){
$genapi = "http://domain.com/api.php";
$result5 = htmlentities(file_get_contents($genapi));
list($first, $last) = explode(':', $result5);
header('Location: minecraft.php?line='.$result5);
}
?>
如果“$ result5”返回“no”然后等待2秒然后再试一次但是如果“$ result5”没有返回“no”则会运行标题行。
答案 0 :(得分:1)
if(isset($_POST['gen'])){
$loop = true;
while($loop){
$genapi = "http://domain.com/api.php";
$result5 = htmlentities(file_get_contents($genapi));
if($result5 !== 'no'){ // check your $result5 based on the value it returns
$loop = false;
list($first, $last) = explode(':', $result5);
header('Location: minecraft.php?line='.$result5);
}
else{
sleep(2);
}
}
}