This article mainly introduces PHP to realize the real-time output, the real time output content method, this article directly gives the realization method, needs the friend may refer to under
Old growing up talking. Pure Memo
For long-running PHP programs, you may need instant output to see what's going on.
The code is as follows:
Header ("Content-type:text/html;charset=utf-8″");
#设置执行时间不限时
Set_time_limit (0);
#清除并关闭缓冲, use this function before outputting to the browser.
Ob_end_clean ();
#控制隐式缓冲泻出, default off, the results of each print/echo or output command are sent to the browser when opened.
Ob_implicit_flush (1);
Cases
The code is as follows:
Ob_end_clean ();
Ob_implicit_flush (1);
while (1) {
Some browsers need content to reach a certain length before outputting
Echo Str_repeat ("
", 200). ' Hello sjolzy.cn
';
Sleep (1);
Ob_end_flush ();
Ob_flush ();
Flush ();
}
According to the example test, the real-time output of PHP to achieve the effect of the content.