PHP Random Number:In this tutorial you will learn about generation of random number in PHP. A random number is becoming more useful these days, like captcha, statistical sampling, cryptography

**PHP Generate Random Numbers:**

A random number is becoming more useful these days, like captcha, statistical sampling, cryptography, computer simulation etc. To generate random number, PHP provides rand() function.

General Format |
int rand(void), int rand(int $min, int $max) | |

Parameters |
$min: Minimum value | $max: Maximum value |

Return Value |
A random value |

**Example :**

<?php

echo "<b>rand() function will generate a random number as follows:</b>".rand();

echo "<br/><b>Same rand() function could generate another random number as follows:</b>".rand();

echo "<br/><b>rand() with parameter will generate a random number as follows:</b>". rand(2,10);

?>

**First Output:**

rand() function will generate a random number as follows:13638Same rand() function could generate another random number as follows:13063rand() with parameter will generate a random number as follows:2

**Second Output (after refreshing the page):**

rand() function will generate a random number as follows:14941Same rand() function could generate another random number as follows:24530rand()with parameter will generate a random number as follows:10