Home  >  Article  >  Backend Development  >  What does rand mean in php

What does rand mean in php

WBOY
WBOYOriginal
2021-12-30 14:06:033088browse

In PHP, the rand() function means generating random integers, and the syntax is "rand(min,max)"; the parameter min is used to set the minimum value of the random number, and the parameter max is used to set the random number. The maximum value of , the return result of this function is a random integer from min to max (including min and max).

What does rand mean in php

The operating environment of this tutorial: windows10 system, PHP7.1 version, DELL G3 computer

The rand in php is What does it mean

The rand function in php represents the meaning of generating random integers.

If you want a random integer between 10 and 100, inclusive, use rand (10,100).

The syntax is as follows:

rand();
or
rand(min,max);

The parameter min is used to specify the minimum value of a random integer, and the parameter max is used to specify the maximum value of a random integer. Both parameters are optional.

The returned result is a random integer between min (or 0) and max (or mt_getrandmax()) (including boundary values).

Examples are as follows:

<?php
echo(rand() . "<br>");
echo(rand() . "<br>");
echo(rand(10,100));
?>

The output results are randomly as follows:

What does rand mean in php

If you are interested, you can click on "PHP Video Tutorial》Learn more about PHP knowledge.

The above is the detailed content of What does rand mean in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn