PHP uses cached instant output (output buffering) method _php Tips

Source: Internet
Author: User
Tags flush browser cache

PHP uses the method of caching the Instant output content (output buffering). Share to everyone for your reference. Specifically as follows:

$buffer = Ini_get (' output_buffering ');
Echo str_repeat (", $buffer + 1); Prevent browser Cache
Ob_end_flush ();//close cache for
($i =1 $i <=10; $i + +) {
  echo '. $i. ' Secondary output. '. ' <br/>\n ";
  Flush (); Flush cache (sent directly to browser) sleep
  (1);
}
echo ' Output complete! ';

The operation effect is as follows:

1th time output.
2nd time output.
3rd time output.
4th time output.
5th time output.
6th time output.
7th time output.
8th time output.
9th time output.
10th time output.
Output Complete!

I hope this article will help you with your PHP program design.

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.