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'r
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 g
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
ailto:[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
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();
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 = mt_rand(
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
7 matches
Mail list logo