How to generate php random number

Here i will tell you how to generate random number using php random function, rand() this is the function to create the random number in php if you are used this function it generate the random number with any of the digits it may display the 5 digit number or 8 digit number or any thing.
 if you are using the specified range in the random number it generates the specified digits.

 If you want two digit random number then you can use this function echo(rand(10,99)); if you can want the 5 digit random number then you can use  echo(rand(10000,99999)) this function this is nothing but you can set the minimum and maximum number , 

This function displays the random number between the the minimum and maximum number you specified in the function. I hope this is really helpful to you to create simple random code. It is very useful to generate opt in some projects. In this example have the demo link check the result of the below example. and also have the download code please check


How to Create random number using php:

<title>How to create random number using php</title>
<h1>Default random number</h1>
<?php echo(rand() . "<br>"); ?><br/>

<h1>Random number for specified(with min number and max number)</h1>
<?php echo(rand(10,1000)); ?><br/>

<h1>Random number with digit</h1>

<h2>If you want two digit number</h2>
<?php echo(rand(10,99)); ?><br/>

<h2>If you want five digit number</h2>
<?php echo(rand(10000,99999)); ?><br/>

<h2>If you want nine digit number</h2>
<?php echo(rand(100000000,999999999)); ?><br/>

<h2>If you want seven digit number</h2>
<?php echo(rand(1000000,9999999)); ?><br/>

<h2>If you want one digit number</h2>
<?php echo(rand(0,9)); ?><br/>

Post a Comment