Let we explain what I mean.
Some time ago, while writing a program in c#, I’ve made following mistake:
int Randomize()
{
Random r=new Random();
return r.Next(0,10);
}
in c#, this is a mistake, because, called several times in a row, this function will return the same value. This is because Random constructor uses time seed, and the time difference between calls was too low (took me an hour to find that one 🙂 ).
Now I’m using rand(...) in php, and I need for the output to always be different, even if 2 scripts are executed at the same time.
Do I have to do something to get this result, or is it designed to work this way?
the
rand()and alsomt_rand()callssrand()andmt_srand()to produce always random results.But here’s an interesting post on php.net:
So, just call
srandmore frequently ormt_rand.