how to create random number in php code example

Example 1: random number generator in php

you can use rand() function for that in php.
Example:
Generate random numbers between 1 to 50
<?php
  echo rand(1,50);
?>

Example 2: creating random number betwwen ranges in php

The rand() function generates a random integer. Tip: If you want a random integer between 10 and 100 (inclusive), use rand (10,100). Tip: The mt_rand() function produces a better random value, and is 4 times faster than rand().

Tags:

Php Example