I would like to know what diff rand of mt_rand and mt_srand; And if you have any other rand.
I would like to know what diff rand of mt_rand and mt_srand; And if you have any other rand.
mt_rand
: Improved random number generator
<?php
echo mt_rand() . "\n";
echo mt_rand() . "\n";
echo mt_rand(5, 15);
?>
mt_srand
: Seed the improved random number generator
<?php
// semente de microsegundos
function make_seed()
{
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
mt_srand(make_seed());
$randval = mt_rand();
?>
srand
: Seed the random number generator
<?php
// Semeia com microsegundos
function make_seed()
{
list($usec, $sec) = explode(' ', microtime());
return $sec + $usec * 1000000;
}
srand(make_seed());
$randval = rand();
?>