mt_srand
Description
The mt_srand of Random for PHP note: There is no need to seed the random number generator with mt_srand() as this is done automatically..
Syntax
mt_srand ([ int $seed [, int $mode = MT_RAND_MT19937 ]] ) : void
Parameters
seed
An arbitrary integer seed value.
mode
Use one of the following constants to specify the implementation of the algorithm to use.
Constant | Description |
---|---|
MT_RAND_MT19937 | Uses the fixed, correct, Mersenne Twister implementation, available as of PHP 7.1.0. |
MT_RAND_PHP | Uses an incorrect Mersenne Twister implementation which was used as the default up till PHP 7.1.0. This mode is available for backward compatibility. |
Return
No value is returned.
Examples
1 · void
<? mt_srand(); $mt_randreturn = mt_rand(); echo $mt_randreturn; ?>
1272039958
2 · seed
<? $seed = time(); mt_srand($seed); $mt_randreturn = mt_rand(); echo $mt_randreturn; ?>
1159916002
3 · mode
<? $seed = time(); $mode = MT_RAND_PHP; mt_srand($seed, $mode); $mt_randreturn = mt_rand(); echo $mt_randreturn; ?>
1159916002