PHP ob_flush,flush in IE buffer Invalid solution

Source: Internet
Author: User

PHP programs are buffered, regardless of the circumstances in which PHP executes (CGI, Web servers, etc.). This function sends all the output of the program so far to the user's browser.
The flush () function does not affect the caching mode of the server or client browser. Therefore, you must use both the Ob_flush () and the Flush () functions to refresh the output buffer.
Individual Web server programs, especially Web server programs under Win32, still cache the output of the script until the end of the program before sending the results to the browser.

*/
for ($i =10; $i >0; $i-)
{
echo $i;
Ob_flush ();
Flush ();
Sleep (1);
}

Microsoft Internet Explorer only starts displaying the page after 256 bytes received, so you must send some extra space to have the browser display the page content

Normal usage

Ob_start ();
Ob_end_flush ();
for ($i = 1; $i <=; $i + +) echo ' www.111cn.net ';

$i = 0;
while (1) {
echo $i;
Sleep (1);
$i + +;
}

For ($i =0 $i <10; $i + +) {
echo $i;
Flush ();
Sleep (1);
}

This code, should be output every second $i, but in practice is not necessarily the case, ie browser may be waiting for 10 seconds, all the output at the same time appear

Ob_end_flush () The//IE8 didn't work.
echo Str_pad ("", 256),//ie need to receive 256 bytes before starting the display

For ($i =0 $i <18; $i + +) {
echo $i;
Flush ();
Sleep (1);
}

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.