An explanation of the simple implementation method of php nginx real-time output

jacklove
Release: 2023-04-02 07:18:01
Original
2328 people have browsed it

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 &#39;现在是:&#39;.date(&#39;H:i:s&#39;).&#39;<br>&#39;;
sleep(5);
echo &#39;五秒后:&#39;.date(&#39;H:i:s&#39;);
Copy after login

##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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!