How to use sleep and usleep function in PHP

How to use sleep and usleep function in PHP

PHP tutorial, explained to use sleep and usleep function in PHP. Sleep is very common method in every language. How sleep function works we need to understand.

use sleep and usleep function in PHP

Sleep function delays the program execution for the given number of seconds.
Usleep delays program execution for the given number of micro seconds.

Following is the php example with sleep function

<?php
echo date('h:i:s') . "<br />";

//stop execution for 30 seconds
sleep(30);

//start again
echo date('h:i:s');

?>

Following is the php example with usleep function

<!--?<span class="hiddenSpellError" pre="" data-mce-bogus="1"-->php
echo date('h:i:s') . &quot;&lt;br /&gt;&quot;;

//stop execution for 30 seconds
usleep(30000000);

//start again
echo date('h:i:s');
?>
How to use sleep and usleep function in PHP
How to use sleep and usleep function in PHP

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.