Seeding a random number generator:
<?phpsrand(mktime());echo(rand());?>The srand() function seeds a random number generator (rand()).
Tip: Starting with PHP 4.2.0, the random number generator is automatically seeded, so there is no need to use this function.
srand( seed );
| parameter | describe |
|---|---|
| seed | Optional. Specifies seeding value. |
| Return value: | none. |
|---|---|
| Return type: | - |
| PHP version: | 4+ |
| PHP change log: | PHP 4.2.0: Random number generator automatically seeded. |