- Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.24, 7.3.0 - 7.3.12
<?php
$gens = [];
for ($i = 0; $i < 1000; $i++) {
$entropy=1;
if (function_exists("posix_getpid"))
$entropy *= posix_getpid();
if (function_exists("memory_get_usage"))
$entropy *= memory_get_usage();
list($usec, $sec) = explode(" ", microtime());
$usec *= 1000000;
$entropy *= $usec;
mt_srand($entropy);
$result = mt_rand();
if (in_array($result, $gens)) {
echo 'Count: ' . count($gens);
echo 'COLLISION: ' . $result;
} else {
$gens[] = $result;
}
}