Example
Seed the random number generator:
html
<?php
mt_srand(mktime());
echo(mt_rand());
?>
Definition and Usage
The mt_srand() function seeds the Mersenne Twister random number generator.
Syntax
text
mt_srand(seed, mode);
Parameter Values
| Parameter | Description |
|---|---|
| seed | Optional. Specifies the seed value |
| mode | Optional. Specifies the algorithm to use. Can be one of the following constants: MT_RAND_MT19937 - uses the fixed, correct Mersenne Twister implementation (which is used from PHP 7.1) MT_RAND_PHP - uses the incorrect Mersenne Twister implementation (which was used up to PHP 7.1) |
Technical Details
| Return Value: | None |
|---|---|
| Return Type: | - |
| PHP Version: | 4+ |
| PHP Changelog: | PHP 4.2.0: Random number generator is now seeded automatically |