PHP implements real-time output and real-time Output Content. php real-time _ PHP Tutorial

Source: Internet
Author: User
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...

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.