Home >>PHP Math Functions >PHP mt_srand() Function
PHP mt_srand() function is used to seed the Mersenne Twister random number generator. It is used only once in script and it must be called before any calls to the mt_rand() function in the script.
Syntax:
mt_srand($seed, $mode);
Parameter | Description |
---|---|
seed | This is an optional parameter. This parameter defines the seed value. |
mode | This is an optional parameter. This parameter defines the algorithm to use. |
Here is an example of mt_srand() function in PHP:
<html> <body> <?php mt_srand(mktime()); echo mt_rand(); ?> </body> </html>
Here is an example of mt_srand() function in PHP:
<html> <body> <?php mt_srand(mktime(),MT_RAND_PHP); echo mt_rand(); ?> </body> </html>