note 10953 modified in function.srand by felipe
| From: | felipe@php.net | Date: | Tue, 22 Jul 2008 18:46:17 +0000 |
| Subject: | note 10953 modified in function.srand by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-142518@lists.php.net to get a copy of this message | ||
Sorry about that... ok, forget have of what I said up there ^.
The code that would prove my example is this:
<?php
srand(5);
echo(rand(1, 10));
srand(5);
echo(rand(1, 10));
srand(5);
echo(rand(1, 10));
?>
Each time you SHOULD get the same answer, but if you did this:
<?php
srand(5);
echo(rand(1, 10));
echo(rand(1, 10));
echo(rand(1, 10));
?>
then the answers would be different, and you'd be letting the random number formula do
it's duty.
--was--
Sorry about that... ok, forget have of what I said up there ^.
The code that would prove my example is this:
srand(5);
echo(rand(1, 10));
srand(5);
echo(rand(1, 10));
srand(5);
echo(rand(1, 10));
Each time you SHOULD get the same answer, but if you did this:
srand(5);
echo(rand(1, 10));
echo(rand(1, 10));
echo(rand(1, 10));
then the answers would be different, and you'd be letting the random number formula do
it's duty.
http://php.net/manual/en/function.srand.php