Let's say you have a simple PHP file that just displays a random number.
When the user hits the submit button, the page will reload and display
another random number.
How often do you need to call mt_srand(); ? Just once? Or each time
the page gets reloaded?
What Version :-)
Check the manual, it has an interesting note:
Note: Since PHP 4.2.0 it's no longer necessary to seed the random number
generator before using it.
HTH
-Brad
Let's say you have a simple PHP file that just displays a random number.
When the user hits the submit button, the
Hi Phil,
How often do you need to call mt_srand(); ?
As of version 4.2.0 you don't have to call it at all. If your PHP
installation is an earlier version than that, call it once per script,
before generating any random numbers, e.g:
mt_srand($seed);
$randomA = mt_rand();
$randomB =
Yeah, I read that,I'm using PHP 4.04...so I do need to see the random
generator.
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 16, 2002 11:35 AM
To: Phil Schwarzmann; [EMAIL PROTECTED]
Subject: Re: [PHP] seeding using mt_srand();
What
:[EMAIL PROTECTED]]
Sent: Wednesday, October 16, 2002 3:40 PM
To: 'Phil Schwarzmann'; [EMAIL PROTECTED]
Subject: RE: [PHP] seeding using mt_srand();
Hi Phil,
How often do you need to call mt_srand(); ?
As of version 4.2.0 you don't have to call it at all. If your PHP
installation is an earlier
On Wednesday 16 October 2002 20:46, Phil Schwarzmann wrote:
So I need to call it each time the page gets reloaded I guess
I can't just have the user load a file called generate.php which has the
mt_srandand then keep calling random.php (which has mt_rand) without
calling generate.php
Hi Phil,
How often do you need to call mt_srand(); ?
once per script, before generating any random
numbers
I can't just have the user load a file called
generate.php which has the mt_srandand then
keep calling random.php (which has mt_rand) without
calling generate.php
Hi Phil,
I'm doing everything correct, although my random
numbers don't seem totally random.
There are two reasons for this.
Firstly, you might not be seeding mt_srand() with a sensible seed - if you
always use 23 as your seed, you'll always get the same sequence of random
numbers. You're
8 matches
Mail list logo