September 2001
Intermediate to advanced
768 pages
32h 45m
English
void srand(int seed) Seeds the random number generator with the given argument.
Returns:
Nothing
Description:
Seeds the random number generator. It’s always a good idea to do this before using the rand() function. Any number can be used to seed the generator, but as a general rule the more random the number you start with, the more random the number you’ll get. Usually, using something like mktime() yields a suitable number. Another common solution is to combine process IDs, the time, and the client’s IP number to produce a more random seed.
Version:
PHP 3, PHP 4
See also:
getrandmax() mt_getrandmax() mt_rand() mt_srand() rand()
Example:
srand(mktime()); echo "A random number: ", rand(); |
Read now
Unlock full access