Jump to: navigation, search

Php rand

From w3cyberlearnings

Contents

PHP function rand

This function returns a random integer. When without any argument, this function will returns a pseudo-random integer between 0 and getrandmax(). If you want to generate a random number between 4 to 8, use rand(4,8).

Syntax rand

  • min: lowest random number to return
  • max: the largest number to return
rand(); 

OR

rand(min, max);

Example 1

<?php

echo rand();
echo "<br/>";
echo rand(1,40);
echo "<br/>";
echo rand(4,9);
?>

Output

Return a different random number for each refresh or program runs.

28517
3
8


Related Links


Navigation
Web
SQL
MISC
References