PHP rand() Function Example

PHP rand() Function Example


Posted in : PHP Posted on : January 28, 2011 at 5:37 PM Comments : [ 0 ]

If you want to generate random integer then use rand() in PHP.

PHP rand() Function Example:

If you want to generate random integer then use rand() in PHP. There are two way for generate random number with rand() function, first is rand() function and second is rand
(min, max) range.

Syntax:

number rand()

number rand(min, max)

min and max is the range of the random integer.

Example:

<?php
echo(rand() . "<br />");
echo(rand(1000,10000))
?>

Output:

The output of this example could be:

15707
1701

Download Example Code

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics