PHP » Miscellaneous » rand()

Syntax:
int rand([int low, int high])
low
Lower limit of the range.
hi
Upper limit of the range.

Returns a random number.

This function returns a random number. If the optional limits are specified, the number returned will be in that range. Otherwise, a number between zero and the value returned by getrandmax() will be returned.

Examples

Code:
<?php

print rand(0, 100) . "<br>";
print rand(-15, 5) . "<br>";
print rand() . "<br>";
print rand() . "<br>";
print rand() . "<br>";
print rand(0, 1000000) . "<br>";

?>
Output:
48
-13
6915
6784
30905
914002
Explanation:

A few random numbers are printed.

See Also: