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 #181447 is a reply to message #181446] Thu, 16 May 2013 22:33 Go to previous messageGo to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma:
Senior Member
SwissCheese wrote:

> On 05/13/2013 05:07 AM, Thomas 'PointedEars' Lahn wrote:
>> It is a string value whose suitability to serve as a numeric value is
>> being tested with is_numeric(). Therefore it matters what the PHP
>> grammar has to say about numeric values.
>>
>>>> is_numeric('x11.11c')
>>>>
>>>> must return FALSE. By contrast, is_numeric('0x11') returns TRUE.
>>>
>>> is_numeric('0x11') has nothing to do with the problem at hand.
>>
>> Yes, it has. Both the added “0” prefix and the omitted “.11c” suffix
>> make “0x11” a proper numeric (hexadecimal integer) representation as per
>> the PHP
>> grammar. Which is what is_numeric() is supposed to test.
>
> is_numeric() checks to see if the first two characters are '0x' (or
> '0X'), but it does not add a leading '0' if the first character is an
> 'x' (or 'X')... nor does it simply omit the part that is not a number
> '.11c'. is_numeric() checks the string as passed without altering it.

Aside from getting a real name and learning to quote only the relevant parts
of what you are replying to, you want to learn to read what you quote more
carefully. I have not even implied that is_numeric() adds anything.

>>>> However, there appears to be an *actual* mismatch between PHP manual
>>>> and implementation in said PHP version as
>>>>
>>>> is_numeric('0b11001001')
>>>>
>>>> returns FALSE when according to the manual it should return TRUE
>>>> (binary integer literals are available since PHP 5.4.0 per the manual,
>>>> and they do compile and properly evaluate in tests there.
>
> Correct as per my other reply.

It is not correct if the manual says something else, and it does. Either
the manual or the implementation is wrong.


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
[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: Wed Nov 27 00:52:16 GMT 2024

Total time taken to generate the page: 0.03590 seconds