while和do while
程序员文章站
2022-07-12 15:09:24
...
先判断下能不能打得过,再确定打不打
public function test1(){
set_time_limit(0);
$x =1;
while($x<=500){
print str_repeat(' ', 50000);
echo "数字是:$x <br>";
ob_flush();
flush();
sleep(1);
$x++;
}
echo '结束';
ob_end_flush();
}
先打一拳,再确定打不打的过
public function test2(){
$x =6;
do {
print str_repeat(' ', 50000);
echo "数字是:$x <br>";
ob_flush();
flush();
sleep(1);
} while ($x <= 5);
echo '结束';
ob_end_flush();
}