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.