PHP rand() function with example

 16 - Mar - 2022
 XpertPhp
 60

In this article, We will explain to you PHP rand() function with example.

PHP rand() function

The rand() function is a built-in function of PHP. which is used to generate a random integer. if this function is called without parameters, it returns a random integer between 0 and RAND_MAX. so you can see our PHP math Function example.

Syntax

rand();
or
rand(min,max);

Example

<?PHP
echo rand();
echo "
";
echo rand(25,30);
?>

Output

1988837313
26

Reference: PHP rand() function