php mt_rand() function


  Translation results:

UK [rænd] US [rænd]

n. The padding between the heel of the shoe and the sole, edge

Plural: rands rand

php mt_rand() functionsyntax

How to use the mt_rand() function?

php The mt_rand() function means to get a random number from the parameter range. The syntax is mt_rand(X,Y). It gets a random number from the two parameter ranges. The random number is greater than or equal to X or Less than or equal to Y

Function:Get a random number from the parameter range

Syntax:mt_rand(X,Y)

Parameters:

ParametersDescription
X Represents the minimum number in the range
YRepresents the maximum number in the range

Instructions: Get a random number from the range of two parameters, the random number is greater than or equal to X or less than or equal to Y

php mt_rand() functionexample

<?php
$i = 1;
$j = 9;
$k = mt_rand($i,$j);
echo "取得的随机数为".$k;
?>

Run instance»

Click the "Run instance" button to view the online instance

Output:

取得的随机数为5
<?php
$i = 10;
$j = 99;
$k = mt_rand($i,$j);
echo "取得的随机数为".$k;
?>

Run Instance»

Click the "Run Instance" button to view the online instance

Output:

取得的随机数为24

Home

Videos

Q&A