This article explains how to implement php nginx real-time output.
The method to enable real-time output in PHP is ob_implicit_flush(),
But it doesn’t work in most cases,
Because most of the output_buffering output buffering in the php.ini configuration It is turned on.
Also zlib.output_compression is often turned on.
In addition to the PHP layer, Nginx's buffer setting proxy_buffering and compression gzip are also mostly turned on. .
I am afraid no one will make this choice to modify the website configuration of the entire server to meet the needs of one or two pages.
Here is a simple method recommended:
set_time_limit(0); ob_end_clean(); ob_implicit_flush(); header('X-Accel-Buffering: no'); // 关键是加了这一行。 echo '现在是:'.date('H:i:s').' '; sleep(5); echo '五秒后:'.date('H:i:s');
This article explains the implementation method of php nginx real-time output. For more related content, please pay attention to the php Chinese website.
PHP Class SoapClient not found processing method
PHP WeChat development: WeChat recording temporary transfer to permanent storage
How to implement the mongoDB singleton mode operation class in php
The above is the detailed content of Implementation method of php nginx real-time output. For more information, please follow other related articles on the PHP Chinese website!