PHP - BUG with filter_var and FILTER_VALIDATE_FLOAT
- by Samuele
I think there is a bug in this filter_var or maybe I'm doing something wrong:
Try this:
$options = array(
'options' => array(
'default' => 3,
'min_range' => 1000.0,
'max_range' => 5000.6,
)
);
$VariableValue2 = 5698;
$VariableValue4 = 5698.2;
$chicco3 = filter_var($VariableValue2, FILTER_VALIDATE_INT, $options);
$chicco4 = filter_var($VariableValue4, FILTER_VALIDATE_FLOAT, $options);
It suppose to don't validate it... Infact the value: 5698 is greater than 5000.6!!!!
But with FILTER_VALIDATE_INT it work FINE!! It return 3 that is the default value in case it don't validate it... PERFECT...
Instead, with FILTER_VALIDATE_FLOAT it validate it... It return 5698.2!!! I'm doing something wrong???
Thank you to everybody...
Samuele