How to use rand in PHP

This article describe about rand() Function in PHP.
  • 1622

rand() Function

This function generate a random integer number.

This function return a random integer between 0 and RAND_MAX. If function is called without parameters.

You can use rand(10,100), if you want a random number between 10 and 100.

Syntax

rand(min, max)

 

Parameter Description
min, max Option. It define the range between random number lie.

Example

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

 

Output


rand-php.jpg

You may also want to read these related articles Click here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.