Php flush() function

不问归期 提交于 2019-12-12 02:47:56

问题


i have this script:

<?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";
?>

This scripts works well.. The problem is when the data flushed the previous messages dissapeared.. How can i fix this script? Thx for advance!!

Edit Well i fix what i was asking with this code:

<?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";
?>

The problem now is that i don't have line break with <br/> I see it also into the screen

来源:https://stackoverflow.com/questions/8734820/php-flush-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!