A brief explanation of the simple implementation method of PHP Nginx real-time output

Source: Internet
Author: User
Tags php language
This article through the example code to introduce the PHP nginx real-time output simple implementation method, very good, has the reference value, needs the friend reference

PHP open Real-time output method is Ob_implicit_flush (),

But it doesn't work in most cases,

Because most of the output_buffering output buffers in the php.ini configuration are on,

And zlib.output_compression are often turned on,

In addition to the PHP layer, there are Nginx buffer settings proxy_buffering, and compression gzip is also mostly open.

For the one or two page requirements, modify the entire server site configuration, I am afraid no one will make this choice.

Here's an easy way to do this:

Set_time_limit (0); Ob_end_clean (); Ob_implicit_flush (); header (' X-accel-buffering:no '); The key is to add this line. Echo ' is now: '. Date (' H:i:s '). ' <br> '; sleep (5); Echo ' Five seconds later: '. Date (' h:i:s ');

Summarize

The above is a small series to introduce you to the PHP nginx real-time output of the simple implementation method, I hope to have some help, if you have any questions welcome to my message, small series will promptly reply to everyone!

Articles you may be interested in:

PHP Comment Syntax specification and naming specification

PHP language comments, single-line comments and multi-line comments related content

Phpstorm regular match Delete blank line, Comment line

Related Article

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.