在PHP中实现间隔几秒执行代码的功能,求高人解释下面的代码。

<?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];
print "--endofsection\n";
ob_flush();
flush();
}
print "Content-type: text/plain\n\n";
print "The end\n";
print "--endofsection--\n";
?>

求header表头的意思
header('Content-type: multipart/x-mixed-replace;boundary=endofsection');
print "\n--endofsection\n";
下面代码输出的含义:
print "Content-type: text/plain\n\n";
print "Part $i\t".$pmt[$i % 4];
print "--endofsection\n";

multipart/x-mixed-replace 声明是分块
boundary=endofsection 声明由endofsection 分隔
print "\n--endofsection\n"; 即分隔标志
print "Content-type: text/plain\n\n"; 声明纯文本
print "Part $i\t".$pmt[$i % 4]; 输出内容
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答