PHP implements Real-Time Output and Real-Time Output content method_php instance

Source: Internet
Author: User
This article mainly introduces PHP's methods for implementing real-time output and Real-Time Output content. This article provides implementation methods directly. If you need them, refer to the old growth talk .. 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.

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.