note 125563 added to filter.filters.sanitize
| From: | ipse at sergiosantos dot me | Date: | Wed, 02 Dec 2020 16:49:48 +0000 |
| Subject: | note 125563 added to filter.filters.sanitize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-215927@lists.php.net to get a copy of this message | ||
Although it's specifically mentioned in the above documentation, because many seem to find this
unintuitive it's worth pointing out that FILTER_SANITIZE_NUMBER_FLOAT will remove the decimal
character unless you specify FILTER_FLAG_ALLOW_FRACTION:
<?php
$number_string = '12.34';
echo filter_var( $number_string, FILTER_SANITIZE_NUMBER_FLOAT ); // 1234
echo filter_var( $number_string, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); //
12.34
?>
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.156.130 (proxied: 2a01:cb1d:8017:f300:62a4:4cff:fe02:4b57)
----
Manual Page -- http://php.net/manual/en/filter.filters.sanitize.php
Edit -- https://master.php.net/note/edit/125563
Del: integrated -- https://master.php.net/note/delete/125563/integrated
Del: useless -- https://master.php.net/note/delete/125563/useless
Del: bad code -- https://master.php.net/note/delete/125563/bad+code
Del: spam -- https://master.php.net/note/delete/125563/spam
Del: non-english -- https://master.php.net/note/delete/125563/non-english
Del: in docs -- https://master.php.net/note/delete/125563/in+docs
Del: other reasons-- https://master.php.net/note/delete/125563
Reject -- https://master.php.net/note/reject/125563
Search -- https://master.php.net/manage/user-notes.php