How to Delay the Execution of a Script with the sleep() Function in PHP

09/04/2021

Contents

In this article, you will learn how to delay the execution of a script with the sleep() function in PHP.

PHP sleep() Function

The sleep function delays execution of the current script.
You can delay execution for a specified number of seconds.

Syntax:

sleep($seconds)

Enter the number of seconds you want to delay.

This function returns 0 if the script was successfully delayed, false on error.