mt_rand() returns a random integer using the mersenne twister algorithm.
Grammar
mt_rand(min,max) description
If the optional arguments min and max are not provided, mt_rand() returns a pseudorandom number between 0 and rand_max. For example, if you want a random number between 5 and 15 (inclusive), use mt_rand(5, 15).
*/
echo mt_rand(); //Generate random numbers
echo "
";
echo mt_rand(); //Generate random numbers
echo "
";
echo mt_rand(10,100); //Generate a random number between 10~00
/*
mt_srand() seeds a mersenne twister random number generator.
Grammar
mt_srand(seed) parameter description
seed is required. Use seed to seed the random number generator.
Description
Starting from php tutorial version 4.2.0, the seed parameter becomes optional. When this item is empty, it will be set to a constant number.
*/
function make_seed() //Generate a random number seed
{
List($usec,$sec)=explode(' ',microtime()); //Split the current number of milliseconds
Return(float) $sec+((float)$usec*100000); //Return value
}
mt_srand(make_seed());
$randval=mt_rand(); //Generate random numbers
return
/*
Grammar
min,max are optional. Specifies the range of random number generation.
Description
*/
echo rand(); //Generate random numbers
echo "
echo rand(); //Generate random numbers
echo "
";
echo rand(5,15); //Generate a random number between 5~15
/*
*/
http://www.bkjia.com/PHPjc/631709.html