PHP rand() function
The rand() function is used to generate a random integer. The rand() PHP function, It generates numbers within a specific range, such as a number between 20 and 50.
syntax:
rand(min,max);
or
rand();
min and max is within rang to generate random number. Let's understand by example.
Example.php
<?php
echo (rand(20, 50) . "<br>");
echo (rand(10, 10000) . "<br>");
echo (rand());
?>
output:
40
9012 939931401 |
Whenever, You will refresh the page output will be different.
Thanks, May this example help you.