php timer facebook games
I have seen online php mmo's and Facebook 开发者_Python百科games that have a timer when you upgrade certain things. Like say I have a level 1 farm and I upgrade to a level 2 farm. It counts down from say 14 minutes. Then after the 14 minutes the upgrading process is complete.
How do they do this programatically speaking?
When doing some action, you take the current time + 14 minutes as target and save it somewhere. You do not unlock the new feature until this time is reached. You can display the remaining time using a simple target time - current time
, which you can update dynamically on the client using Javascript.
This can't be done with PHP (and other server-side languages). The only solution is to use client-side scripting languages like javascript or even Flash. I typically use jQuery along side javascript which is fairly easy to learn.
精彩评论