PHP srand() Function
Definition and Usage
The srand() function seeds the random number generator.
Syntax
srand(Seed)
Parameter | Description |
---|---|
Seed | Optional. Seed the random number generator with seed. |
Description
Starting from PHP 4.2.0 version,Seed Optional. Seed the random number generator with seed.
Tips and Comments
Note:From PHP 4.2.0 onwards, srand() or mt_srand() The function seeds the random number generator, which is now automatically completed.
Example
In this example, we will seed the random number generator:
<?php srand(mktime()); echo(rand()); ?>
Output:
23054