PHP mt_srand () function
Examples
Seeding the random number generator:
<?php
mt_srand(mktime());
echo(mt_rand());
?>
mt_srand(mktime());
echo(mt_rand());
?>
Running instance »
Definition and Usage
mt_srand () function seeded Mersenne Twister random number generator.
Tip: As of PHP 4.2.0, the random number generator is automatically seeded, so there is no need to use this function.
grammar
mt_srand( seed );
参数 | 描述 |
---|---|
seed | 可选。规定播种值。 |
technical details
return value: | no. |
---|---|
Return type: | - |
PHP version: | 4+ |
PHP Update Log: | PHP 4.2.0: random number generator is automatically seeded. |
PHP Math Reference