I would like to get the seed value after the rand()
or mt_rand()
is used. Essentially I want to store the seed so that I can use this seed to continue generating random numbers next time php is executed.
I need a repeatable behavior for unit testing/load testing... and different modules in my applications will use the same seed, so that the sequence of random numbers are generated are reproducible.
Thanks for your input. I couldn't find a method to get the seed. A Random number generator class that exposes the seed would be helpful too.
If you need repeatable behavior, you should seed rand()
or mt_rand()
yourself using srand()
or mt_srand()
and store the seed that you use.
AFAIK the only way to know what the seed in use is is to specify it yourself.
mt_srand($known_value)
Will set your seed to a repeatable value