Computer >> Computer tutorials >  >> Programming >> PHP

usleep() function in PHP


The usleep() function delays execution of the current script for few microseconds.

Syntax

usleep(msec)

Parameters

  • msec − The number of microseconds to delay the script.

Return

The usleep() function returns nothing.

Example

<?php
   echo date('h:i:s') . "<br>";
   // wait for 2 seconds
   usleep(2000000);
   echo date('h:i:s') . "<br>";
   // wait for 5 seconds
   usleep(5000000);
   echo date('h:i:s');
?>

Output

The following is the output.

03:06:08
03:06:10
03:06:15