note 125416 added to function.rand
| From: | Anonymous@php.net | Date: | Mon, 05 Oct 2020 11:07:56 +0000 |
| Subject: | note 125416 added to function.rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-215532@lists.php.net to get a copy of this message | ||
Note that the algorithm change in version 7.1.0 broke the repeatability of a random sequence
initialized with a given value. For example if you have a program like:
<?php
srand($argv[1]);
for ($i = 0; $i < 10; $i++) {
echo rand().PHP_EOL;
}
?>
It will will no longer produce the same results after version 7.1.0. This can be very important for
some kinds of simulations. Hopefully you were using mt_rand() or something better all along,
otherwise you will have some digging to do if you want your program to be able to repeat simulations
from the pre-7.1.0 days... You will need to look in the PHP source archives to discover the
algorithm they used to use and replicate it in your program.
----
Server IP: 45.112.84.4
Probable Submitter: 185.85.3.172 (proxied: 192.86.3.5)
----
Manual Page -- http://php.net/manual/en/function.rand.php
Edit -- https://master.php.net/note/edit/125416
Del: integrated -- https://master.php.net/note/delete/125416/integrated
Del: useless -- https://master.php.net/note/delete/125416/useless
Del: bad code -- https://master.php.net/note/delete/125416/bad+code
Del: spam -- https://master.php.net/note/delete/125416/spam
Del: non-english -- https://master.php.net/note/delete/125416/non-english
Del: in docs -- https://master.php.net/note/delete/125416/in+docs
Del: other reasons-- https://master.php.net/note/delete/125416
Reject -- https://master.php.net/note/reject/125416
Search -- https://master.php.net/manage/user-notes.php