3 ms·
The link at the bottom of the post to the actual explanation is broken. Here's a web archive version: https://web.archive.org/web/20191106104440/http://cod.ifi
by andyljones 6y ago
The link at the bottom of the post to the actual explanation is broken. Here's a web archive version:
https://web.archive.org/web/20191106104440/http://cod.ifies.com/2008/05/php-rand01-on-windows-openssl-rand-on.html https://web.archive.org/web/20191106104440/http://cod.ifies....
TL;DR the default Windows random number generator is (was?) an LCG[1], and that's what PHP calls into by default.
[1] https://en.wikipedia.org/wiki/Linear_congruential_generator https://en.wikipedia.org/wiki/Linear_congruential_generator
- acqq 6y agoI'd expect it's fixed since PHP 7.1.0: https://www.php.net/manual/en/function.rand.php https://www.php.net/manual/en/function.rand.php "Note: As of PHP 7.1.0, rand() uses the same random number generator as mt_rand(). To preserve backwards compatibility rand() allows max to be smaller than min as opposed to returning FALSE as mt_rand()." Maybe somebody could run the code from the OP on Windows with a newer PHP and check?