Home >Backend Development >PHP Tutorial >Three Steps to Using Random Numbers in PHP_PHP Tutorial
I want to make a web page that appears randomly, but using rand() doesn't work. I heard that random numbers need to be initialized, but how to initialize them? Please give me some advice, thank you!
//The first step: initialize the seed
$seedarray =microtime();
$seedstr =split(" ",$seedarray,5);
$seed =$seedstr[ 0]*10000;
//The second step: Initialize the random number generator using the seed
srand($seed);
//The third step: Generate a random number generator within the specified range Random number
$random =rand(10,40);