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

 Live Demo

<?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

Updated on: 30-Dec-2019

36 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements