|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-03-12 00:06 UTC] ianbytchek at gmail dot com
Description:
------------
I might be missing something here, but… Floats are numbers with a floating point. For example:
```
$x = 10;
$x === (float) $x; // false
(float) $x === (float) $x; // true
```
But FILTER_VALIDATE_FLOAT treats integers as floats. Both examples below must return false.
```
filter_var($x, FILTER_VALIDATE_FLOAT) // 10
filter_var('10', FILTER_VALIDATE_FLOAT) // 10
```
Also, why does filter convert value from string into an actual number? Shouldn't that be done only by sanitize filters?
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 21:00:02 2025 UTC |
I agree that the docs can be improved. BTW: you could do filter_var('10', FILTER_VALIDATE_FLOAT, [options=>['decimal'=>true]])