PHP server side timer?

I want to create one timer that appears on my site, I want it to be synchronous for all clients trying to access it. When the client clicks the “increase” button, I want the timer to add 1 minute to the countdown, and I want this change to be reflected for all clients.

Is this achievable through PHP? Any tips / advice to get me started?

Thank!

+5
source share
2 answers

If you need a click on any client to work with all clients, you will need to base the decision on either a survey (update the AJAX hit) or comet programming . The comet programming solution is more complex, but allows real-time pushing timer updates to all clients.

Word of Advice: If your site does not plan to make a large number of asynchronous communications, I just stick to a simple survey. You can even query the AJAX static file and update the static file via PHP (this update needs to be done atomically). This means that every AJAX survey will be very cheap.

+1
source

, , AJAX, , javascript, ..

0

All Articles