Flush controls the output of simulated installation progress

Source: Internet
Author: User

Copyright statement: original works can be reproduced. During reprinting, be sure to mark them as hyperlinks.ArticleOriginal publication, author information, and this statement. Otherwise, legal liability will be held. Http://blog.csdn.net/mayongzhan-ma yongzhan, myz, mayongzhan

First Code
<? PHP
Header ("Content-Type: text/html; charset = UTF-8 ");
Ob_end_clean (); // modify part
For ($ I = 10; $ I> 0; $ I --)
{
Echo $ I;
Flush ();
Sleep (1 );
}
?>
This is to display a number per second. This is the basis. What we need to do is to simulate the installation progress.

Test other functions:
<? PHP
Header ("Content-Type: text/html; charset = UTF-8 ");
For ($ I = 1; $ I <10; $ I ++)
{
Echo $ I. "1 ~~~ <Br/> ";
Ob_flush (); // modify part
Echo $ I. "2 ~~~ <Br/> ";
Flush ();
Echo $ I. "3 ~~~ <Br/> ";
Sleep (5 );
Echo $ I. "4 ~~~ <Br/> ";
}
?>
Test the function. The first output is "1", then wait for 5 seconds, and then output the remaining

We can see that. ob_flush is a split point.
Ob_flush is used to fetch the cache...
Sleep is paused for 5 seconds.
Flush is the cache output.

The entire process is
Echo 1 (in cache now)
Ob_flush: Obtain the cache (1) and prepare the output.
Echo 2 (in cache now)
Flush outputs (1) obtained
Echo 3 (in cache now)
Sleep temporarily stops for 5 seconds
Echo 4 (in cache now)
Echo 1 (in cache now)
Ob_flush: cache (2341) (Please note that the order is the cache order) to prepare the output.
Echo 2 (in cache now)
Flush outputs (2341)
.................
Process continues...

I can see it clearly.
Install Program We can do this:

<? PHP
Header ("Content-Type: text/html; charset = UTF-8 ");
For ($ I = 1; $ I <10; $ I ++)
{
Echo "specific installation operations <br/> ";
Ob_flush (); // modify part
Flush ();
}
?>

In this way, common installation in Windows is implemented, and the effect of the process is displayed.

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.