Teach you how to correctly use the PHP function flush () _php Tutorial

Source: Internet
Author: User
Tags browser cache
For just Learning

1, Flush: Flush the contents of the buffer, output.
function format: Flush ()

This function appears in PHP3, is a very efficient function, he has a very useful function is to refresh the browser cache. Let's take a very obvious example of how the PHP function flush () works.

Example 2.

 
 
  1. < ? PHP
  2. For ($i = 1; $i <= $i + +) print ("");
  3. This is a very important sentence, the structure of the cache
    So that its content only reaches a certain size in order to output from the browser
  4. In other words, if the contents of the cache do not reach
    A certain size, it is not output before the program finishes executing. By
  5. After testing, I found that the bottom of this size is
    256 characters in length. This means that content received by the cache will be
  6. The stream was sent out.
  7. For ($J = 1; $j <= $j + +) {
  8. echo $j. "
  9. ”;
  10. Flush (); This will allow the cache to add new content
    Be squeezed out and displayed on the browser
  11. Sleep (1); Let the program "Sleep" for a second, will let
    You can see the effect more clearly.
  12. }
  13. ?>

PHP2000 's newest PHP chat room is the use of this technology, unfortunately, the source code is not disclosed. Note: If you add Ob_implicit_flush () to the program's header to open the absolute refresh, you can no longer use the PHP function flush () in the program, the advantage is: improve efficiency!


http://www.bkjia.com/PHPjc/446115.html www.bkjia.com true http://www.bkjia.com/PHPjc/446115.html techarticle for just learning 1, flush: Flush the contents of the buffer, output. function format: Flush () This function appears in PHP3, is a very efficient function, he has a very ...

  • 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.