Introduction to the difference between flush (), Ob_flush (), Ob_end_flush () in PHP _php tutorial

Source: Internet
Author: User
The difference between flush (), Ob_flush (), Ob_end_flush ():

First, the next buffer, it is a memory address space, for 4096 (1KB) "found in the php.ini configuration file output_buffering Configuration", PHP has a php output_buffering mechanism, PHP code in the execution of the time, Not immediately the content output, but want to output echo/print content to buffer,buffer full when the data will be handed to the system kernel to TCP to the browser display, when the PHP php output_buffering mechanism (the default is open, Can be turned on by the Ob_start () function, the data in buffer will be sent to the browser only if the data in the PHP buffer reaches the set value.

But the browser also has a cache, some version of the browse when the data reaches 256 bytes of time to output content, flush () can wait for the output of the content to be sent immediately to the client, and Ob_flush () only wait until the buffer full time to output.

Here's a simple example for you to verify:

Copy the Code code as follows:
Prevent browser caching
echo str_repeat ("", 1024);
for ($i =0; $i <5; $i + +) {
echo $i;
Sleep (1);
Flush ();//will output a number every 1s, if using ob_flush () will wait for 5s output together
}
?>

http://www.bkjia.com/PHPjc/326610.html www.bkjia.com true http://www.bkjia.com/PHPjc/326610.html techarticle the difference between flush (), Ob_flush (), Ob_end_flush (): First, say buffer, it is a memory address space, for 4096 (1KB) "In the php.ini configuration file found output_buffering match ...

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