mt_srand
(PHP 4, PHP 5, PHP 7, PHP 8)
Seeds the Mersenne Twister Random Number Generator
Description
Seeds the random number generator with seed or with a random value if no seed is given.
Randomseed Mt19937-tiny-seed
Parameters
seedFills the state with values generated with a linear congruential generator that was seeded with
seedinterpreted as an unsigned 32 bit integer.If
seedis omitted or null, a random unsigned 32-bit integer will be used.modeUse one of the following constants to specify the implementation of the algorithm to use.
MT_RAND_MT19937: The correct Mt19937 implementation, available as of PHP 7.1.0.MT_RAND_PHPUses an incorrect Mersenne Twister implementation which was used as the default up till PHP 7.1.0. This mode is available for backward compatibility.
Feature-8-3-0
Return Values
Void
Changelog
| Version | Description |
|---|---|
| 8.3.0 | seed is now nullable. |
| 7.1.0 | srand()has been made an alias of mt_srand(). |
| 7.1.0 | mt_rand()has been updated to use the fixed, correct, version of the Mersenne Twister algorithm. To fall back to the old behaviour, use mt_srand() with MT_RAND_PHP as the second parameter. |