Hi Philip,
Yes, I have a choice of PHP3 or 4 and this script happened to be in PHP 3 so
I just tweaked it. I didn't realize that one day
$chars[mt_rand(0,$chars_len)] would "no longer work", but at least it is
backwards compatible now. I've made a mental note of that for future
reference.
PHP 3 also barked at
is_numeric()
which I just changed to intval()
I should really do better bounds checking. How about:
$len=intval($len);
if (!$len) $len=8;
kind regards,
bill
Philip Olson wrote:
> It appears the only change you made was :
>
> > $tmp .= $chars[mt_rand(0,$chars_len)];
>
> >From :
>
> > > $tmp .= $chars{mt_rand(0,$chars_len)};
>
> Which is strange. the [] use on strings has been depreciated in favor
> of {} as of php4 but I don't know at what version {} came into being
> exactly. What version of PHP are you running, php3? Or, does anyone know
> much about this?
>
> Anyway, glad it works :)
>
> For informational purposes, this depreciation is stated here :
>
> http://www.php.net/manual/en/language.types.string.php
>
> And for those watching at home, am referring to :
>
> $string = 'abc';
>
> print $string[0]; // depreciated (might not work one day, when?)
>
> vs.
>
> print $string{0};
>
> Both print 'a' though.
>
> Regards,
> Philip Olson
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]