Re: is_numeric_string an hexadecimal numbers ("123" == "0x7B")

From: Date: Tue, 17 Apr 2012 11:47:28 +0000
Subject: Re: is_numeric_string an hexadecimal numbers ("123" == "0x7B")
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-60076@lists.php.net to get a copy of this message
On Tue, 17 Apr 2012 13:35:48 +0200, Simon Schick <simonsimcity@googlemail.com> wrote:
2012/4/17 Nikita Popov <nikita.ppv@googlemail.com>
var_dump('123' == '0x7b'); // true In all other parts of the engine hexadecimal strings are not recognized [3]: var_dump((int) '0x7b'); // int(0)
I personally would rather change the type-conversion for strings to integer ... At least if you force it to do a type-cast (in other words: forcing to get any valuable integer of that string) ...
I think that would be an error. As was mentioned a few months ago when 0b was introduced, no other number format has this behavior. You can't do "123" == "0b10" or "123" == "0876". Extending this hexadecimal oddity instead of eliminating it is inconsistent with the treatment given to those other formats. -- Gustavo Lopes

« previous php.internals (#60076) next »