PHP nginx real-time output example explanation

小云云
Release: 2023-03-19 14:52:01
Original
1943 people have browsed it

This article mainly shares with you the explanation of php nginx real-time output examples, hoping to help everyone.

The method to enable real-time output in PHP isob_implicit_flush(),

but it doesn’t work in most cases,

becausephp .iniIn the configurationoutput_bufferingmost of the output buffering isOnenabled,
andzlib.output_compressionis also often enabled,

In addition to the PHP layer, there are also Nginx buffering settingsproxy_buffering, and compressiongzipare also mostly enabled.
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');
Copy after login

Related recommendations:

PHP outputs messages to the browser in real time_PHP tutorial

PHP realizes instant output and real-time output content method

javascript realizes real-time output of the current time_javascript skills

The above is the detailed content of PHP nginx real-time output example explanation. 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
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!