How to use sleep and usleep function in PHP

Sponsors

Sleep is very common method in every language. How sleep function works we need to understand.

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

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

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

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

Incoming search terms:

You may like following Articles!

This entry was posted in PHP, tutorials and tagged , by Wordpress API. Bookmark the permalink.

About Wordpress API

API means Application Program interface. In Wordpress API we are giving all the information about wordpress API. We worked for many wordpress plugins and themes. We have expertise in PHP, Databases, Graphic Design, Ruby on Rails, Java, Wordpress, Drupal and many CMS. We always give you the best solutions about wordpress and other related topics in This Blog. We will give you always fresh tips and tricks and techniques about wordpress in this blog.

One thought on “How to use sleep and usleep function in PHP

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>