The flush () function is not valid? Can not refresh the output in real time, how to solve it

Source: Internet
Author: User
The flush () function is not valid? Can not refresh the output in real time, how to solve it?
This post was last edited by Zhoumengkang on 2013-05-28 13:46:14

The test code is as follows:
 
  for ($i =0; $i <5; $i + +) {  
Echo '
abc___ '. $i;
Ob_flush ();
Flush ();
Sleep (1);
}
Ob_end_flush ();

It's supposed to be 1 seconds out of the way, right? But the result of my test was 5 seconds before we came out together.
I looked it up on the Internet. "Individual Web server programs, especially Web server programs under Win32, will still cache the output of the script until the end of the program, before sending the results to the browser." "This is the integrated environment for the 64-bit Windows local XAMPP.

Share to:


------Solution--------------------
I'm back, try it.
 
  Echo Str_pad (', 4096);

Set_time_limit (50);
for ($i =0; $i <=5; $i + +) {
echo $i. '
';
Ob_flush ();

Sleep (1);
}
?>

There are a lot of problems in these two days.
This writing in the browser test is not a problem, but there are children shoes said, this practice to write garbage in the buffer, you can try PHP throws an exception, have time to study and share.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.