|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-01-17 20:01 UTC] pmjones88 at gmail dot com
Description: ------------ When using FILTER_SANITIZE_NUMBER_FLOAT with FILTER_FLAG_ALLOW_FRACTION, it seems to allow any number of decimal points, not just a single decimal point. This results in an invalid value being reported as sanitized. Reproduce code: --------------- <?php $val = 'abc ... 123.45 ,.../'; $san = filter_var($val, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); var_dump($san); ?> Expected result: ---------------- float 123.45 Actual result: -------------- string(12) "...123.45..." PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 15:00:02 2025 UTC |
When I try pajoye's suggestion, to use validation, it does not return a float as he says it should. Instead, it (properly) returns false. $val = 'abc ... 123.45 ,.../'; $san = filter_var($val, FILTER_VALIDATE_FLOAT); var_dump($san); // (bool) false What's a guy gotta do to get a float out of that?