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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 05:01:34 2025 UTC