PHP output once per second

Source: Internet
Author: User

First of all, the two configurations in php.ini

Output_buffering Configuration
off: Indicates closing PHP output cache
on: Open an infinitely large output cache
• 4096: Open output cache with size 4096Byte (default)

Implicit_flush Configuration
on: Indicates that the flush () function is automatically called after each output (such as Echo,print), and the direct output
off: On the contrary, flush () will not be called after each output, it will need to wait until the server buffering full before output, but we can use the flush () function instead of it, not open it's OK, but more flexible

In the case of the default output_buffering=4096 and Implicit_flush=off

It is known that Chrome and the Firefox browser output cache is 1000Bytes, that only more than 1000Bytes of content will be output

Look at this procedure.

 <? php  for  ( $i  = 9;  $i  > 0;  $i --) {  str_repeat  (", 122 echo   $i .    ' <br/> ' ;     ob_flush   ();     flush   ();  sleep  (1 ob_end_flush  ();
Str_repeat (", 122) will be repeated 122 times space
Why is it 122?
We know that a byte takes up 8 bits 1000Bytes requires 125 characters to output it will be 126 characters
A 32-digit number of 4 characters
126-4=122

PHP output once per second

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.