Bug #65418 [Opn]: Neither is_numeric() nor intval() recognize '0b...' strings.
| From: | yohgaki@php.net | Date: | Thu, 08 Aug 2013 05:11:50 +0000 |
| Subject: | Bug #65418 [Opn]: Neither is_numeric() nor intval() recognize '0b...' strings. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-180794@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65418&edit=1
ID: 65418
Updated by: yohgaki@php.net
Reported by: brucewlee at verizon dot net
Summary: Neither is_numeric() nor intval() recognize '0b...'
strings.
Status: Open
Type: Bug
Package: Strings related
-Operating System: Windows 7
+Operating System: Irrelevant
-PHP Version: 5.5.1
+PHP Version: 5.4.0 and later
Block user comment: N
Private report: N
New Comment:
binary format was introduced from 5.4.0.
Previous Comments:
------------------------------------------------------------------------
[2013-08-08 04:36:33] brucewlee at verizon dot net
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 this bug report at https://bugs.php.net/bug.php?id=65418&edit=1