Limitless furniture The implementation analysis of PHP set_time_limit0 long connection

Source: Internet
Author: User
Each PHP script limits the execution time, so we need to set a script to execute indefinitely with Set_time_limit, and then use Flush () and Ob_flush () to clear the server buffer and output the return value of the script at any time.
As in the following script:

Copy the Code code as follows:


Header ("Content-type:text/plain");
Set_time_limit (0);
$infoString = "Hello World". "\ n";
while (Isset ($infoString))
{
Echo $infoString;
Flush ();
Ob_flush ();
Sleep (5);
}
?>


When we do, every 5 seconds, we get a row of Hello world, and if you don't press the Stop button, the browser will continue to load on one line.
Through this method, we can complete many functions, such as robot Crawler, instant message board and other programs.

The above describes the limitless furniture php set_time_limit0 long-link implementation analysis, including the limitless furniture aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.