PHP realizes instant output and real-time output content method, php real-time_PHP tutorial

WBOY
Release: 2016-07-13 09:52:20
Original
830 people have browsed it

PHP implements real-time output and real-time output content methods, PHP real-time

I have been talking about it for a long time. . Pure memo

For PHP programs that take a long time to run, you may need to output the content immediately to check the running status.
Copy code The code is as follows:
header(“Content-type:text/html;charset=utf-8″);

#Set execution time without time limit
set_time_limit(0);

#Clear and close the buffer, use this function before outputting to the browser.
ob_end_clean();

#Control implicit buffering, the default is off. When turned on, the results of each print/echo or output command are sent to the browser.
ob_implicit_flush(1);

For example,
Copy code The code is as follows:
ob_end_clean();
ob_implicit_flush(1);
while(1){
//Some browsers require the content to reach a certain length before outputting
echo str_repeat("

", 200).'hello sjolzy.cn
';
Sleep(1);
//ob_end_flush();
//ob_flush();
//flush();
}

Tested according to the example, it achieves the effect of PHP outputting content in real time.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1008021.htmlTechArticlePHP realizes real-time output and real-time output content methods. PHP real-time veteran has talked about it. . Pure memo For PHP programs that take a long time to run, you may need to output the content immediately to check the operation...
Related labels:
php
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!