Re: Re: Seeding rand() at process start?

From: Date: Sat, 22 Sep 2001 12:53:01 +0000
Subject: Re: Re: Seeding rand() at process start?
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-66331@lists.php.net to get a copy of this message
> srand(); > > As of the CVS version of PHP, if you leave the seed out, the rand > implementation will autogenerate it for you (it really wasn't that > hard beforehand, but...) > > I'm currently debating whether seeding at startup is a good idea, > because alot of scripts don't use rand() (alot do I know, but > still), and seeding at startup will cause a slow down in PHP... > another thought is to have rand() check whether or not its been > seeded, and if it has been seeded, use the previous seed, > otherwise, seed the generator (I'm currently leaning towards the > latter). Having a state flag around rand() and srand() which indicates, upon a call to rand, whether or not srand() has been called is a great idea. When PHP is acting as part of a web page, seeding the random number generator is a fairly tricky thing to maintain. If you don't do it in the module, a user would have to do it in the PHP environment, and that is a little more difficult.

« previous php.dev (#66331) next »