Results 1 to 4 of 4

Thread: How can I make PHP wait

  1. #1
    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?

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    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:

    sleep(time_period_in_seconds);
    or

    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.

  3. #3
    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.

  4. #4
    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():

    int sleep (int $seconds)

Similar Threads

  1. Should I buy HTC one S or wait ?
    By Diedrick in forum Portable Devices
    Replies: 7
    Last Post: 13-04-2012, 11:26 PM
  2. Should I Buy A PS3 Now Or Wait For PS4?
    By Kordell in forum Portable Devices
    Replies: 6
    Last Post: 19-10-2010, 07:34 PM
  3. PHP Wait timer?
    By Angelica Maria in forum Software Development
    Replies: 6
    Last Post: 13-05-2010, 12:13 PM
  4. How to make a visitor wait during a search
    By Govardhann in forum Software Development
    Replies: 5
    Last Post: 29-01-2010, 10:58 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,047,416.87449 seconds with 16 queries