Math Rand in PHP

In this article I am going to explain PHP math rand function.
  • 1859

Introduction

The PHP math functions are used to handle values within the range of integer and float types. In this article I describe some more of the PHP math functions. 

PHP Rand() function

The PHP rand function generates a random integer. If you call rand without a parameter then it will return a random integer between 0 and RAND_MAX.

Syntax

rand  (min, max)


Parameters in Rand function

It has two parameters; they are:
 

Parameter Description
min It specifies minimum range as a integer.
max It specifies maximum range as a integer.

Example of Rand function 

<?php

echo ("Random number without the range: "rand() ."</br>");

echo ("Random number between 10 to 100: ".rand(10,100)."</br>");

?>

Output

math-rand-function-in-php.jpg

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.