Implementation method of php nginx real-time output

jacklove
Release: 2023-03-27 14:22:01
Original
1297 people have browsed it

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');
Copy after login

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!

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