PHP Delay Program Execution using sleep() Example




PHP Delay Program Execution using sleep() Example

Hi Dev,

In this example, you will learn php delay program execution using sleep() example. it's simple example of php delay the program execution for the specified number of seconds. it's simple example of using sleep to add delay or increase execution time. I’m going to show you about sleep function in php with code examples.

In this example The sleep() function in PHP is an inbuilt function which is used to delay the execution of the current script for a specified number of seconds, so Let's see following example with output.

Example :



// current time

echo date('h:i:s') . "<br>";

//sleep for 5 seconds


//start again

echo date('h:i:s');



10:49:00 First is current time

10:49:05 Second time is sleep for 5 seconds

I hope it could help you...