note 8911 added to srand
| From: | richard at zend dot com | Date: | Thu, 05 Oct 2000 16:02:28 +0000 |
| Subject: | note 8911 added to srand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-6126@lists.php.net to get a copy of this message | ||
*ALWAYS* use
(double)microtime()*1000000
as your seed.
Do *NOT* just use time(). Do not add an extra 0 to make it "bigger".
Take care to call srand() only *ONCE* per script.
Calling
(double)microtime()*1000000
once, and only once, per script gives you the maximum "randomness" you can get.
Anything else is sub-standard. If you want to understand why, there's a lot of reading you
need to do... I don't know enough to point you to the best text to get started on this
reading. For now, just trust the PHP Developers, okay?
http://www.php.net/manual/function.srand.php