rand
Generates a pseudo-random integer within a specified range or between 0 and getrandmax().
Parameters
main.php
Return Values
int
Returns a pseudo-random integer
On success:Random integer between min and max (inclusive)
On failure:Never fails - always returns an integer value
Notes
- Not cryptographically secure - use random_int() for security purposes
- Since PHP 7.1, rand() is an alias of mt_rand()
- Both parameters are optional - without them returns 0 to getrandmax()
- Use srand() to seed the random number generator if needed
Changelog
- 4.0.0: Function was introduced
- 7.1.0: Became an alias of mt_rand()