srand ((double) microtime() * 1000000);
$passcode = rand();
in NT, i got passcode less than 6 digits.
but when i put this site on a UNIX, the passcode is more than 6 digits.
why?
Found this in about 30 seconds on php.net (search function: rand)..
chad at bellevue dot com 23-Apr-2002 02:59 The min and max integer values for specifying the random number's range are different in Linux and Windows. In Linux you can have a huge number while in Windows you are limited to an integer between -32768 to 32767.
chad at bellevue dot com 23-Apr-2002 02:59
The min and max integer values for specifying the random number's range are different in Linux and Windows. In Linux you can have a huge number while in Windows you are limited to an integer between -32768 to 32767.
I know that doesn't answer "why", but I think that would be a question directly for the developers...
The "why" would be the difference in rand() functions supplied by the compiler's libraries (since PHP uses those to implement its own rand()). For a platform-independent RNG, use [man]mt_rand[/man].
Thanks for clearing that up Weedpacket! I learned something today!