[Online] Questions about php timers

Source: Internet
Author: User
[Online help] Questions about php timers new users help questions about php timers: I want to write a timer on php, but php does not seem to support this function, & nbsp; I checked the methods of many friends on the Internet, but none of them works. & nbsp; I want to implement it through an endless loop, but it doesn't work either. I 'd like to ask my sister-in-law for help... & Lt ;? Phpignore _ [online help] about php timer
Questions about the php timer:
I want to write a timer in php, but php does not seem to support this function. I checked a lot of methods on the Internet, but none of them work,
I want to implement it through an endless loop, but it doesn't work either. ask for help...
 Ignore_user_abort (true );
Set_time_limit (0 );
Function test (){
Echo "test timer! ";
}

Do {
Sleep (3 );//
Test ();
} While (1)
?>
Php
------ Solution --------------------
What do you want?
------ Solution --------------------
Jquery latency, combined with ajax.
------ Solution --------------------
Crontab/scheduled task
------ Solution --------------------
Reference:
Questions about the php timer:
I want to write a timer in php, but php does not seem to support this function. I checked a lot of methods on the Internet, but none of them work,
I want to implement it through an endless loop, but it doesn't work either. ask for help...
PHP code? 123456789101112

In fact, your method is feasible. The value should not be echo, because the echo information stored in the buffer during PHP running is not output before the program runs, so you cannot see the effect.
You can replace echo with a database operation statement, for example, adding 1 piece of data in less than 5 seconds.
------ Solution --------------------
In addition, it is recommended that you do not add ignore_user_abort during testing. this operation will run in the background, even if the browser is closed, the execution will continue unless it is stopped from the process.
------ Solution --------------------
When the webpage is closed, it will not be updated.
For example, if you access the service once every minute, users with a time difference of more than one minute between the validity period and the current time are naturally not online.
------ Solution --------------------
You can use window. setInterval (); combined with ajax to continuously send data or request data to a php file.
------ Solution --------------------
You can use recursive functions to implement this function.

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.