Reputation: 369
random.php
$min=1;
$max=13031;
$ran_num = mt_rand($min,$max);
echo $ran_num;
This is working fine on my local host, but when I run it on my server, it always return the same number. not sure what is going on.
Update: I am running a wordpress site, and I put the random.php in the theme folder. I also have eaccelerator installed, this might be the issue, I am looking into it now
Upvotes: 2
Views: 2093
Reputation: 7343
Wordpress may use cache, and if you reload the page, it loads from cache, so you will see the same random number again and again. It has nothing to do with PHP version in this particular case - to fix this, it is needed to disable the wordpress cache.
Upvotes: 0
Reputation: 166429
By default modern PHP creates different number for mt_rand
(it's uses libc random number generator), so the problem can be somewhere else.
This can likely to be caused by some caching, for example check the followings:
Upvotes: 0
Reputation: 24146
If your server has PHP lower than 4.2 - you need to call to mt_srand before you can use mt_rand
Upvotes: 2