note 39984 added to function.rand
| From: | marinebaneatnospamhotmailnospam dot com at rn2 dot php dot net | Date: | Tue, 17 Feb 2004 17:27:22 +0000 |
| Subject: | note 39984 added to function.rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-65311@lists.php.net to get a copy of this message | ||
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!!! <<<
----
Manual Page -- http://www.php.net/manual/en/function.rand.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39984
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39984&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39984&report=yes
Search -- http://master.php.net/manage/user-notes.php