The following procedure is I found on the Internet, he commented that the first sentence is very critical, but I found that the first sentence did not work, no output 300 spaces. And I deleted the first sentence. The result is exactly the same.
for ($i = 1; $i <=, $i + +) print ("");
This sentence is very key, the structure of the cache so that its content can only reach a certain size to be exported from the browser
In other words, if the content of the cache does not reach a certain size, it will not be output until the program finishes executing. By
After testing, I found that the bottom limit of this size is 256 characters in length. This means that content received by the cache will be
The stream was sent out.
for ($j = 1; $j <=; $j + +) {
echo $j. " ";
Flush (); This will cause the cache additions to be squeezed out and displayed on the browser
Sleep (1); Let the program "Sleep" a second, will let you see the effect more clearly
}
?>
I wrote a program myself, I found the Ob_flush () changed to flush (), the first one does not output, I remember that flush () is the content of the output buffer immediately ah, why not output it.
Ob_end_flush (), and the ASP Response.End is also different Oh, ob_end_flush (), after the content will still output ah, there is no way to let the contents of the back stop output
Ob_start ();
echo "the first article";
Ob_flush (); Immediately output the contents of the buffer
echo "Second article";
Ob_get_clean (); Clears the contents of the buffer
echo "Article III";
Ob_end_flush ();
?>
Reply to discussion (solution)
Only IE has a buffer full or the end of the transfer to explain the phenomenon of incoming content
A space is not an HTML element, no matter how many, it will only show a
The function of flush () is to eject the contents of the PHP system buffer to the customer
The role of Ob_flush () is to eject the contents of the PHP user buffer into the PHP system buffer
The role of Ob_end_flush () is to eject the contents of the PHP user buffer into the PHP system buffer and close the PHP user buffer
The role of Ob_end_clean () is to empty the contents of the PHP user buffer and close the PHP user buffer
Response uses a completely different mechanism (response is the device)
Only Ob_end_clean () after Ob_start () is equivalent to Response.End
I still do not understand the system buffer and user buffer, on the Internet also search for this information, just said that PHP support multi-level buffer. It seems that you can build an n-level buffer, and I think it is possible to build buffers in the buffer. PHP is more complex than ASP in this respect.
A system buffer is a PHP output buffer that can be output_buffering to control its size
Whenever the PHP program has output will be stored in the inside, to be full or at the end of the program sent to the user once
Flush () is forcing the output of his content
User buffers are buffers that are opened with Ob_start (), and each ob_start () is one that allows nesting
If you try this code, I'll be fine under the ie,firefox,chrome.
'; Ob_flush (); flush (); Sleep (1);}? >
On the server-side push data client immediate display problem, in fact, will be affected by Web server, browser, and code three aspects.
You need to understand the whole process first:
The Web server also has buffer buffers, the size of which will be related to the number of bytes the server has reached before being pushed to the client browser.
Then the browser will also have a buffer, the number of bytes received before the display.
Your code just fills in some blanks to trick the browser into letting the browser display the content instantly. And the problem may be on the server side, there is no data sent to the client.
For how the server is set up, Apache seems to default.
Nginx needs to turn off gzip, then set fastcgi_buffers,fastcgi_buffer_size equivalent to line. You can check it out for yourself.
In addition, different browsers for buffer buffers are not the same as the rules, to achieve a variety of browser support, you try to fill out a little bit.
IIS Magager-system.webserver/handlers Responsebufferlimit is set to 0,
Php.ini-output_buffer =off
for ($i = 1; $i <=, $i + +) print ("");
Floating through only the moderator's answer to make a mark
If you try this code, I'll be fine under the ie,firefox,chrome.
'; Ob_flush (); flush (); Sleep (1);}? >
Thank.