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("
Tested according to the example, it achieves the effect of PHP outputting content in real time.