|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-03-01 14:12 UTC] dosergio at ig dot com dot br
Description:
------------
I think that is_numeric should return TRUE if you pass chr(0) or chr(1) to it because this chars are stored in database as BITs, that are numeric in the binary context. Would php adopt it ?
I had to use a strange conditional because of this supposed "bug":
[code]
if( is_numeric($myvar) || ord($myvar) < 2) {
# to check char 0 or 1 that are BITS, binary numeric.
}
[/code]
Test script:
---------------
if( is_numeric( chr(0)) || is_numeric(chr(1)) )
echo "is_numeric is great!";
else
echo "is_numeric might be a little buggy";
Expected result:
----------------
is_numeric shoud recognize chr(0) and chr(1) as numeric, as they are chars for bit information.
Actual result:
--------------
is_numeric says chr(0) and chr(1) are both NOT numeric.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 20:00:01 2025 UTC |
if( is_numeric( chr(0)) && is_numeric(chr(1)) ) # <-- changed to && echo "is_numeric is great!"; else echo "is_numeric might be a little buggy";