3v4l.org

run code in 500+ PHP versions simultaneously
<?php mt_srand(42); $first = [mt_rand(), rand()]; mt_srand(42); echo 'mt_rand/rand repeat after mt_srand(): ', var_export($first === [mt_rand(), rand()], true), "\n"; mt_srand(42); $first = @lcg_value(); mt_srand(42); echo 'lcg_value repeats after mt_srand(): ', var_export($first === @lcg_value(), true), "\n"; srand(42); $first = @lcg_value(); srand(42); echo 'lcg_value repeats after srand(): ', var_export($first === @lcg_value(), true), "\n";
Output for 8.2.0 - 8.2.36, 8.3.0 - 8.3.37, 8.4.1 - 8.4.28, 8.5.0 - 8.5.13, 8.6.0
mt_rand/rand repeat after mt_srand(): true lcg_value repeats after mt_srand(): false lcg_value repeats after srand(): false

preferences:
14.39 ms | 1164 KiB | 6 Q