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 Notes
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