开发者

Php polling Is it required

I want to write a php code that displays a html button only till so开发者_开发知识库me point of time.

Since php is a scripting language and code get executed only when the html page is rendered,

I was thinking that instead of polling I can just check the time at the time the page is getting rendered. If the current time does not satisfy my condition then I simply won't echo that button else I can echo the button.

Is this approach right or should I do polling ?


Once the page loads, php has no more control. If you have displayed a button, and you want to remove it after a certain time frame, you will need to use javascript anddo some kind of setTimeout() to schedule that. Obviously, the javascript won't be 100% reliable (if someone has js disabled, or a browser not supporting js).


I don't understand why you would use polling. PHP already has all needed functionality to both check the time and to conditionally output HTML. The only thing that may cause trouble is timezones, but that can be handled by adding an offset to the relevant times.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜