我有这个脚本:
<?php
header('Content-type: multipart/x-mixed-replace;boundary=endofsection');
print "\n--endofsection\n";
$pmt = array("-", "\\", "|", "/" );
for( $i = 0; $i <10; $i ++ ){
sleep(1);
print "Content-type: text/plain\n\n";
print "Part $i\t".$pmt[$i % 4]."<br />";
print "--endofsection\n";
ob_flush();
flush();
}
print "Content-type: text/plain\n\n";
print "The end\n";
print "--endofsection--\n";
?>
这个脚本效果很好.. 问题是当数据刷新以前的消息消失了。 我该如何修复这个脚本? Thx for advance !!
修改 好吧,我用这段代码解决了我的问题:
<?php
header('Content-type: multipart/mixed;boundary=endofsection');
//print "\n--endofsection\n";
$pmt = array("-", "\\", "|", "/" );
print "Content-type: text/plain\n\n";
for( $i = 0; $i <10; $i ++ ){
sleep(1);
echo "Part $i\t".$pmt[$i % 4]." \n";
//ob_flush();
flush();
};
print "The end\n";
print "--endofsection--\n";
?>
现在的问题是我没有<br/>
的换行符我也看到了屏幕