|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-10-24 16:40 UTC] john_judy at homedecorators dot com
Description: ------------ When running the filters FILTER_SANITIZE_NUMBER_INT or FILTER_SANITIZE_NUMBER_FLOAT, decimal points are being removed. The filter information from phpinfo() (run on our FreeBSD machine which still has 5.2.3, although this bug happens on PHP version 5.2.4 in Windows XP also) is as follows: filter Input Validation and Filtering enabled Revision $Revision: 1.74 $ Directive Local Value Master Value filter.default unsafe_raw unsafe_raw filter.default_flags no value no value Reproduce code: --------------- <?php $test = "456.78"; echo $test."\n"; echo filter_var($test,FILTER_SANITIZE_NUMBER_INT)."\n"; echo filter_var($test,FILTER_SANITIZE_NUMBER_FLOAT, array(FILTER_FLAG_ALLOW_FRACTION))."\n"; ?> Expected result: ---------------- 456.78 456.78 456.78 Actual result: -------------- 456.78 45678 45678 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 12 13:00:01 2025 UTC |
From the friendly manual: " options Associative array of options or bitwise disjunction of flags. If filter accepts options, flags can be provided in "flags" field of array. For the "callback" filter, callback type should be passed. " echo filter_var($test,FILTER_SANITIZE_NUMBER_FLOAT, array("flags" => FILTER_FLAG_ALLOW_FRACTION))."\n"; And about FILTER_SANITIZE_NUMBER_INT: "Remove all characters except digits and +-." (the dot in that sentence is NOT the decimal dot!)