hi guys this is the code:
<?php
$action=0;
$looprunned=0;
while($action < 10){
$looprunned++;
$rand = rand(0,10000);
if($rand==1){
$action++;
}
}
echo "loop runned {$looprunned} times";
?>
the problem here: after hitting refresh few times i'm getting same set of numbers and messege. so instead of random number generator i have feeling that something is saving already generated php file and then gives same result. i tested it with chrome and firefox and both browsers for strange reasons are giving me same set of numbers after hitting F5; i'm using Xampp V3.2.2.
so after each refresh i always getting: loop runned 122199 times, loop runned 104014 times, loop runned 101467 times , AND THAN IT REPEATING ITSELF: loop runned 122199 times, loop runned 104014 times, loop runned 101467 times and so on. so what is this? by the code i'm supposed to get different random result each time but i'm getting this all the time. any help? why is this happening?
Aucun commentaire:
Enregistrer un commentaire