|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-11-11 16:31 UTC] pierre dot php at gmail dot com
[2017-01-20 14:48 UTC] neil at crook dot es
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 22:00:01 2025 UTC |
Description: ------------ Even when setting the locale to one that uses commas for the decimal point separator in a floating point number, the FILTER_VALIDATE_FLOAT and FILTER_SANITIZE_NUMBER_FLOAT constants do not recognize the comma as a proper separator. For internationalization, these filters should allow the comma (or take the locale into account and allow the comma). Reproduce code: --------------- <?php setlocale(LC_ALL, 'de_DE'); $float1 = '42.3'; $float2 = '42,3'; var_dump(filter_var($float1, FILTER_VALIDATE_FLOAT)); var_dump(filter_var($float2, FILTER_VALIDATE_FLOAT)); var_dump(filter_var($float1, FILTER_SANITIZE_NUMBER_FLOAT, array('flags' => FILTER_FLAG_ALLOW_FRACTION))); var_dump(filter_var($float2, FILTER_SANITIZE_NUMBER_FLOAT, array('flags' => FILTER_FLAG_ALLOW_FRACTION))); ?> Expected result: ---------------- float(42.3) float(42.3) string(4) "42.3" string(4) "42.3" Actual result: -------------- float(42.3) bool(false) string(4) "42.3" string(3) "423"