PHP implementation of real-time output, real-time output content method _php Example

Source: Internet
Author: User

Old growing up talking. Pure Memo

For long-running PHP programs, you may need instant output to see what's going on.

Copy Code code 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
Copy Code code 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 ("<div></div>", 200). ' Hello sjolzy.cn<br/> ';
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.