Thursday, January 28, 2016

PHP RANDOM NUMBER: Generate Random Numbers in PHP

A random function rand() is used to generate random integer numbers. I already done posting article about generating random numbers in Java.

Syntax for random number

rand();

or if you want to specify numbers from a certain range then you used this syntax

Syntax for random number with limit
rand(min,max);

The following php code will generate random numbers.

PHP Code
<?php
echo rand();
?>
while following php code will generate random numbers between 100-2000.

PHP Code
<?php
echo rand(100,2000);
?>

Possible Output
101 / 507 / 1250 / 899 / 1999

PHP RANDOM NUMBER: Generate Random Numbers in PHP

PHP RANDOM NUMBER: Generate Random Numbers in PHP Rating: 4.5 Diposkan Oleh: Emoblazz

0 comments:

Post a Comment