|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-05-18 12:40 UTC] cmbecker69 at gmx dot de
Description: ------------ In PHP 5.4.15 the definition of is_numeric() is in ext/standard/type.c (line 300ff)[1]. The relevant function to do the check for arguments of type string is is_numeric_string_ex() in Zend/zend_operators.h (line 109ff)[2]. Apparently special support for strings in binary as well as octal notation is missing; only strings in decimal and hexadecimal notation are recognized as such (strings in octal notation are treated as being decimal). I have filed this issue as documentation problem, but it might be considered an implementation bug. [1] <http://lxr.php.net/xref/PHP_5_4/ext/standard/type.c> [2] <http://lxr.php.net/xref/PHP_5_4/Zend/zend_operators.h> Test script: --------------- var_dump(is_numeric('0b1')); Expected result: ---------------- bool(true) Actual result: -------------- bool(false) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 12:00:01 2025 UTC |
This is bugged also for hex numbers: print "526e948280122 " .(is_numeric("526e948280122") ? "numeric" : "not numeric"). PHP_EOL; print "526a948280122 ". (is_numeric("526a948280122") ? "numeric" : "not numeric"). PHP_EOL; print "0x526a948280122 ". (is_numeric("0x526a948280122") ? "numeric" : "not numeric"). PHP_EOL; print "526f948280122 ". (is_numeric("526f948280122") ? "numeric" : "not numeric"). PHP_EOL; output is: 526e948280122 numeric 526a948280122 not numeric 0x526a948280122 numeric 526f948280122 not numeric tested with versions 5.5.4-1 and 5.4.4 (Debian version 5.4.4-14+deb7u5)