[thelist] parsing numbers trap

Scott Dexter sgd at ti3.com
Fri Jun 15 11:17:31 CDT 2001


> 
> Numbers starting with zero are interpreted by PHP as octal 
> (which go from
> 00 to 07). 08 and 09 are illegal octal numbers and taken for zero
> which shows totally confused dates.
> 

Helluva tip!

What sucks, is that javascript does the same thing. It shows up in the
parseInt() function. When used like so: parseInt('08') --it will get treated
as an octal number. To get around this in javascript, always (!) explicitly
set the radix: parseInt('08',10). There, now all your parseInt's will be
treated as base 10 =)

sgd




More information about the thelist mailing list