Friday, March 29, 2024
Google search engine
HomeLinux TutorialsSleep for a random time in PHP

Sleep for a random time in PHP

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

YOU CAN SUPPORT DEVNINJA WITH A CUP OF COFFEE

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online. to search or browse the published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or more ) as a token of appreciation.

Support Us

DevNinja
DevNinja
System & Network Administrator Ninja
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

eleven − 9 =

- Advertisment -
Google search engine

Most Popular

Recent Comments