mt_srand
Description
NOTE: There is no need to seed the random number generator with mt_srand() as this is done automatically.
Syntax
mt_srand(
?int $seed = null,
int $mode = MT_RAND_MT19937
): voidParameters
seed
An arbitrary integer seed value.
mode
Use one of the following constants to specify the implementation of the algorithm to use.
| Value | Constant | Description |
|---|---|---|
| 0 | MT_RAND_MT19937 | Uses correct Mersenne Twister implementation. |
| 1 | MT_RAND_PHP | Uses incorrect Mersenne Twister implementation. Available for backward compatibility. |
Return
No value is returned.
Examples
1 · void
<? mt_srand(); $mt_randreturn = mt_rand(); echo $mt_randreturn;
1771202777
2 · seed
<? $seed = time(); mt_srand($seed); $mt_randreturn = mt_rand(); echo $mt_randreturn;
1558980698
3 · mode · MT_RAND_MT19937
<? $seed = time(); $mode = MT_RAND_MT19937; mt_srand($seed, $mode); $mt_randreturn = mt_rand(); echo $mt_randreturn;
1558980698
4 · mode · MT_RAND_PHP
<? $seed = time(); $mode = MT_RAND_PHP; mt_srand($seed, $mode); $mt_randreturn = mt_rand(); echo $mt_randreturn;
1558980698