Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 11-09-2009
Member
 
Join Date: Jul 2009
Posts: 77
How can I make PHP wait

I have developed a webpage in PHP that accesses server at regular interval of time. However, sometimes it requires more time to get the response from the server. So I need for the form to wait few seconds and then proceed. Is there any method in PHP that allows me to make the page wait till the timer goes off?
Reply With Quote
  #2  
Old 11-09-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: How can I make PHP wait

The below are the functions that you can implement in your web page to force PHP wait for certain time interval:

Quote:
sleep(time_period_in_seconds);
or

Quote:
usleep(time_period_in_milliseconds);
But make sure while using sleep(), you also mention that the 30 second is the run time limit so that it doesn't exceed while sleeping.
Reply With Quote
  #3  
Old 11-09-2009
Member
 
Join Date: Nov 2008
Posts: 1,192
Re: How can I make PHP wait

According to me, you can try out time(). It will return a timestamp that increments with each second. Get the current time and subtract the stored time with this and if it is less then either display a message or allow them to wait for the remaining time before getting a response.
Reply With Quote
  #4  
Old 11-09-2009
Member
 
Join Date: Nov 2005
Posts: 1,323
Re: How can I make PHP wait

The best way would be to show the error message to the user informing to let them continue, however, in my case, if I want to insert a delay time in my PHP script I call the function sleep(). The syntax of sleep():

Quote:
int sleep (int $seconds)
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How can I make PHP wait"
Thread Thread Starter Forum Replies Last Post
Should I buy HTC one S or wait ? Diedrick Portable Devices 7 13-04-2012 11:26 PM
Should I Buy A PS3 Now Or Wait For PS4? Kordell Portable Devices 6 19-10-2010 07:34 PM
PHP Wait timer? Angelica Maria Software Development 6 13-05-2010 12:13 PM
How to make a visitor wait during a search Govardhann Software Development 5 29-01-2010 10:58 PM


All times are GMT +5.5. The time now is 12:15 PM.