Home » Sleep for a random time in PHP

Sleep for a random time in PHP

  • by

If you want your PHP program to halt/sleep for a random period of time, use the folowing:

sleep ( rand ( int min, int max));

*sleep is in seconds

so:

sleep ( rand ( 2, 4));

will sleep for 2 to 4 seconds.

ref:
http://php.net/manual/en/function.sleep.php
http://php.net/manual/en/function.rand.php

Tags:

Leave a Reply

Your email address will not be published.

eleven + eight =