From:             brucewlee at verizon dot net
Operating system: Windows 7
PHP version:      5.5.1
Package:          Strings related
Bug Type:         Bug
Bug description:Neither is_numeric() nor intval() recognize '0b...' strings.

Description:
------------
Neither is_numeric() nor intval() recognize '0b...' strings. 

Test script:
---------------
Code:
$as = array("0x10", "16", "020", "0b10000");
foreach($as as $v) {
        echo "The function is_numeric('" . $v . "') returns ";
        if (is_numeric($v)) { echo("true"); } else { echo("false"); };
        echo ".<br>";
}

Output:
The function is_numeric('0x10') returns true.
The function is_numeric('16') returns true.
The function is_numeric('020') returns true.
The function is_numeric('0b10000') returns false.

Code:
$as = array(["0x10", 16], ["16", 10], ["020", 8], ["0b10000", 2]);
foreach($as as $v) {
        echo "The function intval('" . $v[0] . "', " . $v[1] . ") returns " .
intval($v[0], $v[1]) . ".<br>";
                }
Output:
The function intval('0x10', 16) returns 16.
The function intval('16', 10) returns 16.
The function intval('020', 8) returns 16.
The function intval('0b10000', 2) returns 0.



-- 
Edit bug report at https://bugs.php.net/bug.php?id=65418&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=65418&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=65418&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=65418&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=65418&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=65418&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=65418&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=65418&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=65418&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=65418&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=65418&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=65418&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=65418&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=65418&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65418&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=65418&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=65418&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=65418&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65418&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=65418&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=65418&r=mysqlcfg

Reply via email to