Re: rand(), mt_rand(), and my inability to make either of them random.
| From: | April | Date: | Fri, 26 Jan 2001 21:18:47 +0000 |
| Subject: | Re: rand(), mt_rand(), and my inability to make either of them random. | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-36877@lists.php.net to get a copy of this message | ||
lol, nm, you weren't. Why does it return Warning: Use of undefined constant
U - assumed 'U' in c:\apache\htdocs\temp\random.php on line 4 if I don't use
quotes, though?
annnnyway, I'm going to give up on this. Thanks, though.
----- Original Message -----
From: "April" <april@ponymail.com>
To: "Robert Collins" <rcollins@Insight.com>; "PHP General"
<php-general@lists.php.net>
Sent: Friday, January 26, 2001 3:15 PM
Subject: Re: [PHP] rand(), mt_rand(), and my inability to make either of
them random.
> Thanks. It doesn't need to be completely random, just, more random than
> "1". The occasional 3 would be enough for me.
>
> And,t hank you very very much. You forgot the quotes around the U, btw.
> *huggss*
>
> ----- Original Message -----
> From: "Robert Collins" <rcollins@Insight.com>
> To: "'April'" <april@farstrider.org>; "PHP General"
> <php-general@lists.php.net>
> Sent: Friday, January 26, 2001 2:58 PM
> Subject: RE: [PHP] rand(), mt_rand(), and my inability to make either of
> them random.
>
>
> > this is a function that I wrote to solve this problem, but it is almost
> > impossible to get a truly random number you can get somthing pretty
close
> by
> > seeding with somthing like the time function, using the seconds since
> epoch
> > and this should be hard to duplicate.
> >
> > <?php
> > function random_number($config, $lownum, $highnum){
> >
> > $time = date(U);
> > $seed = srand($time);
> > $rand = rand($lownum, $highnum);
> >
> > echo "<FONT FACE=\"$fontstyle\" SIZE=\"$fontsize\"
> > COLOR=\"$fontcolor\">$rand</FONT>";
> >
> > $lownum = "1";
> > $highnum = "100";
> > random_number("config.inc.php", $lownum, $highnum);
> >
> > }
> > ?>
> >
> > -----Original Message-----
> > From: April [mailto:april@farstrider.org]
> > Sent: Friday, January 26, 2001 1:50 PM
> > To: PHP General
> > Subject: [PHP] rand(), mt_rand(), and my inability to make either of
> > them random.
> >
> >
> > I have this scriptlet:
> >
> > $items = 6;
> > $randnum = rand(1,$items);
> > echo $randnum . "<br><br>";
> >
> > Always, no matter how many times I hit refresh, it'll always return the
> > lowest possible value, in this case 1. If I have rand(4,$items), it
> returns
> > four.
> >
> > So I tried mt_rand(), with this:
> >
> > $items = 6;
> > $randnum = mt_rand(1,$items);
> > echo $randnum . "<br><br>";
> >
> > This always, without fail, returns the highest possible value. 6 in
this
> > case.
> >
> > I'm using Apache/4.0.3pl1 on Windows 2000, locally, just to develop.
> Could
> > this be a cache type problem? Could the gods be conspiring to drive me
> > steadily insane?
> >
> > April
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-general-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>