Re: FILTER_SANITIZE_NUMBER_FLOAT non/sense [message #177014 is a reply to message #177011] |
Thu, 16 February 2012 11:53 |
Thomas Mlynarczyk
Messages: 131 Registered: September 2010
Karma:
|
Senior Member |
|
|
Michael Fesser schrieb:
>>> $ php -r "echo filter_var('456,999', FILTER_SANITIZE_NUMBER_FLOAT,
>>> FILTER_FLAG_ALLOW_THOUSAND);"
>>> 456,999
>> Hm, it is still messed up, in the default setup it eats points and commas.
> Correct. [...]
I consider this a very strange definition of "correct". The point (pun
intended) of floats is precisely to be able to have a decimal point. It
is absolutely ridiculous to filter that out by default. Do you have to
explicitly allow "@" when filtering e-mail addresses?
From the manual:
>
> | FILTER_SANITIZE_NUMBER_FLOAT [...]
> | Remove all characters except digits, +- and optionally .,eE.
^^^^^^^^^^^^^^^^
I would consider that appropriate when filtering for numbers in general,
but certainly not when explicitly dealing with floats. Is there a
rationale for this WTF?
Greetings,
Thomas
--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
|
|
|