echo from php “as it goes”

前端 未结 6 1887
耶瑟儿~
耶瑟儿~ 2021-01-20 18:27

what was the way to print results from a php script while it\'s printing stuff before the script ends? i tried to play with output buffer, putting sleep() between echos to t

6条回答
  •  难免孤独
    2021-01-20 18:59

    There are 2 solutions:

    1) Deactivate the output_buffering in php.ini

    2) When using loops use this for example:

    for ($i = 1; $i <= 3; $i++) {
      echo md5(rand())."
    "; flush(); ob_end_flush(); sleep(1); }

提交回复
热议问题