Bug #66399 [NEW]: Inconsistent runtime support for integer binary/hex syntax

From: Date: Fri, 03 Jan 2014 11:46:48 +0000
Subject: Bug #66399 [NEW]: Inconsistent runtime support for integer binary/hex syntax
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-183555@lists.php.net to get a copy of this message
From: benjamin at zikarsky dot de Operating system: PHP version: 5.5.7 Package: Strings related Bug Type: Bug Bug description:Inconsistent runtime support for integer binary/hex syntax Description: ------------ While PHP's support for hexadecimal and binary (>=5.4) integer literals works fine at "compile"-time, it is inconsistent/lacking at runtime. E.g. in strings. - is_numeric($v) detects hexadecimal format but not the binary version - casting to int (both with (int) and intval($v)) is not supported for either format I am not sure if this is a bug/missing feature or unwanted behavior. I think it should be at least consistent for is_numeric. Test script: --------------- <?php $bin = "0b100"; $hex = "0x04"; var_dump((int) $bin); var_dump((int) $hex); var_dump(is_numeric($bin)); var_dump(is_numeric($hex)); var_dump(intval($bin)); var_dump(intval($hex)); Expected result: ---------------- int(4) int(4) bool(true) bool(true) int(4) int(4) Actual result: -------------- Tested with: PHP 5.5.7 (cli) (built: Jan 3 2014 11:33:48) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies Output: int(0) int(0) bool(false) bool(true) int(0) int(0) -- Edit bug report at https://bugs.php.net/bug.php?id=66399&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66399&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66399&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66399&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=66399&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=66399&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=66399&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=66399&r=needscript Try newer version: https://bugs.php.net/fix.php?id=66399&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=66399&r=support Expected behavior: https://bugs.php.net/fix.php?id=66399&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=66399&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=66399&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=66399&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66399&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=66399&r=dst IIS Stability: https://bugs.php.net/fix.php?id=66399&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=66399&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=66399&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=66399&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=66399&r=mysqlcfg

« previous php.bugs (#183555) next »