FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » bug in is_numeric
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: bug in is_numeric [message #181405 is a reply to message #181394] Wed, 15 May 2013 13:19 Go to previous messageGo to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma:
Senior Member
SwissCheese wrote:

> norman@amd64x2:~$ php -a
> Interactive shell
>
> php > $a = 'x';
> php > if(is_numeric($a)) { echo 'okay'; } else { echo 'not okay'; }
> not okay
> php > $a = '11';
> php > if(is_numeric($a)) { echo 'okay'; } else { echo 'not okay'; }
> okay
> php > $a = 'x11.11c';
> php > if(is_numeric($a)) { echo 'okay'; } else { echo 'not okay'; }
> not okay
> php > $a = '0x1111c';
> php > if(is_numeric($a)) { echo 'okay'; } else { echo 'not okay'; }
> okay
>
>
> As per http://us3.php.net/manual/en/function.is-numeric.php :
>
> "Hexadecimal (e.g. 0xf4c3b00c), Binary (e.g. 0b10100111001), Octal (e.g.
> 0777) notation is allowed too but only without sign, decimal and
> exponential part."

But AISB, the implementation is contradicting the documentation (or vice-
versa) because the a string argument containing the binary format causes
is_numeric() to return FALSE in PHP 5.4.4 and PHP 5.4.14 (when according to
the above it should have returned TRUE). It is not possible to determine by
testing whether the octal format is considered numeric because of itself or
because it is considered decimal. Incidentally, you have neglected to test
those two formats.


PointedEars
--
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
-- Richard Cornford, cljs, <cife6q$253$1$8300dec7(at)news(dot)demon(dot)co(dot)uk> (2004)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: problem encrypting data (AES_ENCRYPT/AES_DECRYPT)
Next Topic: Debian: php fast-cgi along with mod_php
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 07:04:44 GMT 2024

Total time taken to generate the page: 0.05058 seconds