PHP implements real-time output and real-time Output Content methods, and php implements real-time output. PHP implements real-time output and real-time Output Content methods .. Pure memo for PHP programs that run for a long time may need to output content in real time to view the methods for running PHP to achieve real-time output and real-time output content. php real-time
Let's talk about it .. Pure memo
For PHP programs that run for a long time, you may need to output the content in real time to view the running status.
The code is as follows:
Header ("Content-type: text/html; charset = utf-8 ″);
# Setting the execution time is not limited
Set_time_limit (0 );
# Clear and close the buffer and use this function before outputting it to the browser.
Ob_end_clean ();
# Control implicit buffering. the default value is off. when it is enabled, the results of each print/echo or output command are sent to the browser.
Ob_implicit_flush (1 );
For example,
The code is as follows:
Ob_end_clean ();
Ob_implicit_flush (1 );
While (1 ){
// Some browsers need to output the content after it reaches a certain length.
Echo str_repeat ("
", 200). 'Hello sjolzy.cn
';
Sleep (1 );
// Ob_end_flush ();
// Ob_flush ();
// Flush ();
}
The test by example achieves the real-time output of PHP content.
Let's talk about growth .. For PHP programs that run for a long time, the pure memo may need to output the content in real time to view the running results...