21,887
社区成员
发帖
与我相关
我的任务
分享
<?php
ignore_user_abort(true);
header( 'Content-Type: text/html;charset=utf-8' );
echo str_pad("",1000); //输出1000个空格
echo 'begin...<br>';
flush();
for($i=0;$i<10;$i++)
{
echo 'loading '.$i.'0%<br>';
if ( connection_aborted() )
{
exit;
}
flush();
sleep(1);
}
echo 'ok';
<?php
ignore_user_abort(true);
header( 'Content-Type: text/html;charset=utf-8' );
echo 'begin...<br>';
flush(); //直接推送到浏览器
for($i=0;$i<10;$i++)
{
echo 'loading '.$i.'0%<br>';
// 如果浏览器已关闭
if ( connection_aborted() )
{
exit; //如果希望关了浏览器后程序继续执行,把这行去掉即可
}
flush();
sleep(1);
}
ob_end_clean();
ob_implicit_flush(true);
for ($i=10; $i>0; $i--)
{
echo $i . "<br/>";
sleep(1);
}