[PHP] seeding using mt_srand();

2002-10-16 Thread Phil Schwarzmann
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?

Re: [PHP] seeding using mt_srand();

2002-10-16 Thread bbonkosk
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

RE: [PHP] seeding using mt_srand();

2002-10-16 Thread Jon Haworth
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 =

RE: [PHP] seeding using mt_srand();

2002-10-16 Thread Phil Schwarzmann
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

RE: [PHP] seeding using mt_srand();

2002-10-16 Thread Phil Schwarzmann
:[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

Re: [PHP] seeding using mt_srand();

2002-10-16 Thread Jason Wong
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

RE: [PHP] seeding using mt_srand();

2002-10-16 Thread Jon Haworth
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

RE: [PHP] seeding using mt_srand();

2002-10-16 Thread Jon Haworth
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