Are you curious how “random” the (better) number generator is when it comes generating ? You can check generated number, times that x is between y and z, and the total times of refreshing the page with f5. This is just a test and just for curiosity.
<?php
# Session start
session_start();
# Seed the generator
mt_srand((double)microtime()*1000000);
# Random between min, max
$random = mt_rand(1,50);
# Set defaults
if (!isset($_SESSION['total'])):
$_SESSION['between'] = 0;
$_SESSION['total'] = 0;
endif;
# Keep track
if ($random > 20 && $random < 40)
{
$_SESSION['between']++;
}
# Show results
echo '<br />Generated number: '. $random;
echo '<br />Between: '. $_SESSION['between'];
echo '<br />Total:'. ++$_SESSION['total'];
?>
Mail this!
- Comments (0)
- PingBacks (0)
- TrackBacks (0)


» Latest comments