This article introduces you to the simple implementation method of php nginx real-time output through example code. It is very good and has reference value. Friends who need it can refer to it
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 is On,
and zlib.output_compression It is also often turned on.
In addition to the PHP layer, Nginx's buffering 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').'<br>'; sleep(5); echo '五秒后:'.date('H:i:s');
##Summary
The above is a simple implementation method of php nginx real-time output introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time! Articles you may be interested in:Detailed explanation of PHP comment syntax specifications and naming specifications
php language comments, single-line comments and multi-line comments related content
phpstorm regular matching to delete empty lines and comment lines
The above is the detailed content of An explanation of the simple implementation method of php nginx real-time output. For more information, please follow other related articles on the PHP Chinese website!