#46742 [Com]: is_numeric function not working as per "common sense"

From: Date: Tue, 16 Dec 2008 15:51:05 +0000
Subject: #46742 [Com]: is_numeric function not working as per "common sense"
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-132038@lists.php.net to get a copy of this message
ID: 46742 Comment by: zyss at mail dot zp dot ua Reported By: ben at ajmadison dot com Status: Open Bug Type: Feature/Change Request Operating System: any PHP Version: 5.2.6 New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#132038) next »