I\'m writing a script that needs to execute concurrent tasks in PHP.
I ran a little test and ran into strange result. I\'m using pcntl_fork to generate a child. The
That is because all children start with the same state (fork() duplicates the code and data segments). And since rand and mt_rand are pseudorandom generators, they will all generate the same sequence.
You will have to re-initialize the random generator, for example with the process/thread ID or read a few bytes from /dev/urandom.