note 121047 added to filter.filters.validate

From: Date: Thu, 04 May 2017 14:47:04 +0000
Subject: note 121047 added to filter.filters.validate
Groups: php.notes 
Request: Send a blank email to php-notes+get-209054@lists.php.net to get a copy of this message
A word to the wise regarding floats. $t = '312041.25 € instead of 896.70 €'; echo filter_var ($t, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); will return 312041.25896.70 which is likely not what you were expecting. In 2007 someone suggested it's not acceptable (see https://bugs.php.net/bug.php?id=40156&edit=2) but it was flagged "not a bug" because these kind of filters are only supposed to filter out illegal characters. Of course if you were to use FILTER_VALIDATE_FLOAT it would just return that the input is not valid. ---- Server IP: 72.52.91.14 Probable Submitter: 109.168.65.113 ---- Manual Page -- http://php.net/manual/en/filter.filters.validate.php Edit -- https://master.php.net/note/edit/121047 Del: integrated -- https://master.php.net/note/delete/121047/integrated Del: useless -- https://master.php.net/note/delete/121047/useless Del: bad code -- https://master.php.net/note/delete/121047/bad+code Del: spam -- https://master.php.net/note/delete/121047/spam Del: non-english -- https://master.php.net/note/delete/121047/non-english Del: in docs -- https://master.php.net/note/delete/121047/in+docs Del: other reasons-- https://master.php.net/note/delete/121047 Reject -- https://master.php.net/note/reject/121047 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#209054) next »