|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76435 Float with decimals Filter issue with Ca_fr locale
Submitted: 2018-06-09 00:29 UTC Modified: 2018-06-09 12:55 UTC
From: joel dot lamothe dot 42 at gmail dot com Assigned:
Status: Open Package: Filter related
PHP Version: 7.1.18 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
25 + 40 = ?
Subscribe to this entry?

 [2018-06-09 00:29 UTC] joel dot lamothe dot 42 at gmail dot com
From manual page:

When setting the locale to fr_CA, using filter_var with decimal numbers is behaving irregularly since the comma is the decimal separator in fr_CA, the sanitized float becomes an int losing its comma.

filter_var is either not coded in a locale dependent way or this below scenario is not being caught in its handling of the locale.

Test script:
setlocale(LC_ALL, 'fr_CA.utf-8');
$number = 25 / 2;

echo $temp;

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-06-09 12:55 UTC]
Not only is FILTER_SANITIZE_NUMBER_FLOAT not locale aware, but
there also is no possibility to manually override the decimal and
thousand separators[1] (like for FILTER_VALIDATE_FLOAT), which
rather limits its usefulness.

In this case one can get around this limitation by using the flag
FILTER_FLAG_ALLOW_FRACTION[2], but that's quite a hack.

[1] <>
[2] <>
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Sep 26 03:01:23 2020 UTC