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

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.

Leave a Comment