note 39984 deleted from function.rand by aidan
| From: | aidan@php.net | Date: | Sat, 10 Jul 2004 02:32:56 +0000 |
| Subject: | note 39984 deleted from function.rand by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72960@lists.php.net to get a copy of this message | ||
Note Submitter: marinebane at nospamhotmailnospam.com
----
With some versions of PHP (including 4.3.4 ), there is a problem with Windows XP and rand(). In
short (as this is not a bug report), if you have any POST or GET requests to the page, rand() can
generate the same number each time.
This bug is already listed on bugs.php.net, but a solution to the bug posted there is that you use
srand() at the start of your code.
example that could cause problems:
<?php
print rand();
?>
example of safe rand() usage:
<?php
srand();
print rand();
?>
>>> IF IN DOUBT, USE srand() FIRST!!! <<<