Chat room Technology-how to refresh _php tutorials when only new speeches are available

Source: Internet
Author: User
In the active refresh, the program should constantly judge whether there is a new speech, if not repeat,
Here I introduce a method similar to C language programming effect
A time stamp because the general PHP script execution has a time limit
$delaytime = 0;
Cycle
while (1)
{
Judging whether there is a new statement, I $filename here to hold the total number of speeches, $last is the last statement that has been shown
$message = file ($filename);
$number = $message [0];
1 seconds delay
Sleep (1);
Time Stamp increase
$delaytime + +;
Exit the loop if the time stamp is close to the allowable script run time
if ($delaytime >) break;
Exit the loop if you have a new statement
if ($number > $last) break;
}
Handling Updates
... ...
This will not happen the page constantly refreshed, very annoying situation!!!

http://www.bkjia.com/PHPjc/532099.html www.bkjia.com true http://www.bkjia.com/PHPjc/532099.html techarticle in the active refresh, the program to constantly judge whether there is a new speech, if not repeat, here I introduce a similar C programming effect of the method//a time tag, because one ...

  • Related Article

    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.