Re: Numerical string comparison - octal and hex.

From: Date: Wed, 13 Jan 2010 16:49:06 +0000
Subject: Re: Numerical string comparison - octal and hex.
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-46700@lists.php.net to get a copy of this message
Richard Quadling wrote:
> Hello.
> 
> In looking at numer vs string comparison, I think I've found an oddity.
> 
> You can successfully compare hex strings ...
> 
> var_dump(255 == '0xff');
> 
> but not octal strings ...
> 
> var_dump(63 == '077');
> 
> 
> Is this a bug (lack of octal support) or an unexpected feature (hex support)?

We don't have octal strings in PHP.  Only native octal.
eg.
var_dump(63 == 077);

Why?  Mostly because octal strings is more likely to cause incorrect
behaviour than both regular numeric strings and hex strings.

-Rasmus


Thread (5 messages)

« previous php.internals (#46700) next »