#46742 [Opn->Bgs]: is_numeric function not working as per "common sense"
| From: | johannes@php.net | Date: | Tue, 16 Dec 2008 17:41:03 +0000 |
| Subject: | #46742 [Opn->Bgs]: is_numeric function not working as per "common sense" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-132042@lists.php.net to get a copy of this message | ||
ID: 46742
Updated by: johannes@php.net
Reported By: ben at ajmadison dot com
-Status: Open
+Status: Bogus
Bug Type: Feature/Change Request
Operating System: any
PHP Version: 5.2.6
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
.
Previous Comments:
------------------------------------------------------------------------
[2008-12-16 15:51:04] zyss at mail dot zp dot ua
It shouldn't.
is_numeric() works just in the same way as in other languages,
specifically as described in PHP docs:
"Numeric strings consist of optional sign, any number of digits,
optional decimal part and optional exponential part. Thus +0123.45e6 is
a valid numeric value. Hexadecimal notation (0xFF) is allowed too but
only without sign, decimal and exponential part."
This doesn't prevent one from implementing his own algorithm with a
custom function.
------------------------------------------------------------------------
[2008-12-03 17:54:02] ben at ajmadison dot com
Description:
------------
is_numeric("1343.32") returns true, but is_numeric("1,343.32") returns
false. Since the comma is used just for visual representation, the
number represented is still numeric and is_numeric function should
return true.
Reproduce code:
---------------
echo is_numeric("1,343.32");
Expected result:
----------------
true
Actual result:
--------------
false
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46742&edit=1