When you run this php script, every time you will get a random number but what about if you want to get random number within a range???? To get a random number within a range is also a quite easy method just you need to pass the two arguments to the rand() function. First argument will be the starting number of the range and second argument will be the ending number of the range, now every time you will get a random number that will lie in this range, let’s have a look over example to clearly understand what I try to explain
Now some time you will get 1, some time 2 and some time 3, etc. It will not give you any number less than 1 or greater than 5
So this is the way to generate random numbers in php.