Hi, ill show you how to use 'mt_rand' 'srand' and a really complicated one that makes hexadecimal numbers.
lets start off with the 'mt_rand' function.
Now for the 'srand' function.
I dont actually know what the difference it to the random number functions but they do their job .
The next one will create a hexadecimal code which is very useful for sessions and cookies, so that people will never guess them!
echo
lets start off with the 'mt_rand' function.
Code:
//Minimum number
$min = 1;
//Maximum number
$max = 100;
//Put mt_rand into a variable
$random = mt_rand($min, $max);
echo "Our random number of the day is: " . $random;
Now for the 'srand' function.
Code:
//Minimum number
$min = 1;
//Maximum number
$max = 100;
srand((double) microtime()*1000003);
//1000003 because it is a prime number
//convert it to a variable
$random = rand($min, $max);
echo "Another random number today is: " . $random
The next one will create a hexadecimal code which is very useful for sessions and cookies, so that people will never guess them!
Code:
$hex = sha1(uniqid(mt_rand()));
echo "Todays impossible to guess hex code is: " . $hex;
echo