Generate random numbers:
<?phpecho(rand() . "<br>");echo(rand() . "<br>");echo(rand(10,100));?>The rand() function generates random integers.
Tip: If you want a random integer between 10 and 100, inclusive, use rand (10,100).
Tip: The mt_rand() function is a better choice for generating random values, returning results 4 times faster than the rand() function.
rand();orrand( min,max );
parameter | describe |
---|---|
min | Optional. Specifies the minimum number to return. The default is 0. |
max | Optional. Specifies the maximum number to return. The default is getrandmax(). |
Return value: | A random integer between min (or 0) and max (or mt_getrandmax()), inclusive. |
---|---|
Return type: | Integer |
PHP version: | 4+ |
PHP change log: | PHP 4.2.0: Random number generator automatically seeded. |