Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a function similar to setTimeout() (JavaScript) for PHP?

The question sort of says it all - is there a function which does the same as the JavaScript function setTimeout() for PHP? I've searched php.net, and I can't seem to find any...

like image 369
Latze Avatar asked Aug 08 '10 18:08

Latze


1 Answers

There is no way to delay execution of part of the code of in the current script. It wouldn't make much sense, either, as the processing of a PHP script takes place entirely on server side and you would just delay the overall execution of the script. There is sleep() but that will simply halt the process for a certain time.

You can, of course, schedule a PHP script to run at a specific time using cron jobs and the like.

like image 138
Pekka Avatar answered Sep 21 '22 11:09

Pekka