software






 

Question by  Matthew49 (21)

How do you add a few second timeout in php?

I need to create a few second delay or wait in php.

 
+7

Answer by  hb77 (12)

You can use sleep function to add a few second timeout in php. Just use sleep(seconds), this will delay the execution time by the number of 'seconds' given to the sleep function. If you want a 10 second timeout, you can say sleep(10). Please refer to the PHP manual for more information on sleep function.

 
+7

Answer by  emstorm73 (26)

The easiest way to create a pause in PHP is to use the sleep() or usleep() commands. The sleep() command will pause for the number of seconds provided as an argument. The usleep() command uses microseconds, in case you need higher precision.

 
+6

Answer by  madox (6)

A timeout in PHP can be achieved by calling the "sleep"-function. The sleep-function takes one parameter: Number of seconds to delay the execution. e.g. "sleep(4);" stops the execution for 4 seconds.

 
+6

Answer by  veracruz (12)

To create a delay in PHP use the sleep() function. Syntax is: sleep(seconds); Where the "seconds" argument is a numeric constant or numeric variable with the number of seconds of the delay. Examples: sleep(10); // Produces a ten-second delay $a = 60; sleep($a); // Produces a sixty-seconds delay

 
+6

Answer by  Tails (130)

The sleep() function does just that. It takes one argument, the number of seconds to wait, and stops the execution of the entire script during that time. For example, "sleep(5);" will make the script pause for 5 seconds before continuing.

 
+6

Answer by  Dave95 (36)

Make a call to the sleep() function. Insert sleep() where you want to stop, and use the number of seconds you want to sleep as the argument. Ex: sleep(5);

 
+6

Answer by  PowerIsMe (844)

You can use the function sleep() and pass an integer value to it indicating the number of SECONDS for which you want it to sleep. Or you can try usleep() which accepts integer number of MICRO-Seconds. In both cases, this is a server side code. Meaning that the server will stall for that long and then deliver the full page.

 
+4

Answer by  gigo (1706)

You can overwrite the default timeout of your page by calling the function set_time_limit( number of seconds ). As alternative you can change the global value for max_execution_time. Its value is taken in seconds as well.

 
+4

Answer by  Tails (130)

Use the sleep() function. It takes the number of seconds to wait as an argument. For example, sleep(5) will stop execution for 5 seconds before continuing.

 
You have 50 words left!