php 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 rand() functionsyntax

How to use the rand() function?

php rand() function means to get a random number from the parameter range. The syntax is 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: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 rand() functionexample

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

Run instance»

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

Output:

随机输出1-9之间的一个整数
<?php
echo rand(1,100);
?>

Run Instance»

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

Output:

随机输出1-100之间的一个整数

Home

Videos

Q&A