Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delay Function PHP

please tell me how to make a delay function to delay functions!

DelayCommand(functionToDelay, Delaytime);

..? in php 5.3+

thanks for any help

like image 201
james Avatar asked Jul 23 '11 22:07

james


People also ask

How do you delay a function in PHP?

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. The sleep( ) function accepts seconds as a parameter and returns TRUE on success or FALSE on failure.

Is there a wait function in PHP?

Description ¶ The wait function suspends execution of the current process until a child has exited, or until a signal is delivered whose action is to terminate the current process or to call a signal handling function.

What is the use of sleep in PHP?

The sleep() function delays execution of the current script for a specified number of seconds. Note: This function throws an error if the specified number of seconds is negative.

How do I stop a PHP script?

How we can use the PHP's exit function to stop the execution of remaining code. exit is usually used right after sending final output to a browser, or to stop a script in case there was an error. When exit is used it will stop code-execution completely and exit PHP.


1 Answers

function delayCommand($callback, $delayTime) {
    sleep($delayTime);
    $callback();
}
like image 117
karim79 Avatar answered Sep 30 '22 14:09

karim79