tags:

views:

38

answers:

2

Hi,

I want to write a php code that displays a html button only till some 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 ?

+1  A: 

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.

Ignacio Vazquez-Abrams
hmmm.. that's precisely what i was asking u.. thanks...
Anand
It's a bit worse than that... I'm not even certain what "polling" is supposed to mean in the context of the question.
Ignacio Vazquez-Abrams
What I meant by polling was that do I keep a thread or something that checks the time say every one minute and then it must check whether the time satisfies the given condition and then we must display the button based on whether a condition has been evaluated to true or false
Anand
+1  A: 

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).

Jage