php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #46742 is_numeric function not working as per "common sense"
Submitted: 2008-12-03 17:54 UTC Modified: 2008-12-16 17:41 UTC
From: ben at ajmadison dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.6 OS: any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ben at ajmadison dot com
New email:
PHP Version: OS:

 

 [2008-12-03 17:54 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-16 15:51 UTC] 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-16 17:41 UTC] johannes@php.net
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

.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 09:01:33 2024 UTC