(PHP 4, PHP 5, PHP 7)
mt_srand — 锟斤拷锟斤拷一锟斤拷锟斤拷锟矫碉拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟�
$seed
] ) : void
锟斤拷
seed
锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷帧锟� 没锟斤拷锟借定 seed
锟斤拷锟斤拷时锟斤拷锟结被锟斤拷为锟斤拷时锟斤拷锟斤拷
Note: 锟斤拷 PHP 4.2.0 锟金,诧拷锟斤拷锟斤拷要锟斤拷 srand() 锟斤拷 mt_srand() 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟� 锟斤拷锟斤拷为锟斤拷锟斤拷锟斤拷锟斤拷系统锟皆讹拷锟斤拷傻摹锟�
seed
锟斤拷选锟斤拷锟斤拷锟斤拷值
没锟叫凤拷锟斤拷值锟斤拷
锟芥本 | 说锟斤拷 |
---|---|
4.2.0 |
The seed becomes optional
and defaults to a random value if omitted.
|
5.2.1 | The Mersenne Twister implementation in PHP now uses a new seeding algorithm by Richard Wagner. Identical seeds no longer produce the same sequence of values they did in previous versions. This behavior is not expected to change again, but it is considered unsafe to rely upon it nonetheless. |
Example #1 mt_srand() 锟斤拷锟斤拷
<?php
// seed with microseconds
function make_seed()
{
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
mt_srand(make_seed());
$randval = mt_rand();
?>