This article mainly through the example code to introduce the PHP nginx real-time output simple realization method, very good, has the reference value, needs the friend reference, hoped can help everybody.
The real-time output method in PHP is Ob_implicit_flush (), but it does not work in most cases because the output_buffering output buffers in the php.ini configuration are mostly on, and zlib.output_ Compression is also often opened, in addition to the PHP layer, there are Nginx buffer settings proxy_buffering, and compression gzip is 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 ');