Skip to content

Commit cfe679c

Browse files
committed
Add a warning for FILTER_SANITIZE_NUMBER_FLOAT
This integrates user note 125563
1 parent 6305d20 commit cfe679c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

reference/filter/constants.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,31 @@
10541054
</listitem>
10551055
</varlistentry>
10561056
</variablelist>
1057+
<warning>
1058+
<simpara>
1059+
If the <constant>FILTER_FLAG_ALLOW_FRACTION</constant> flag is not used,
1060+
then the decimal separator is removed, altering the value received.
1061+
</simpara>
1062+
<informalexample>
1063+
<programlisting role="php">
1064+
<![CDATA[
1065+
<?php
1066+
$number = '12.34';
1067+
1068+
var_dump(filter_var($number, FILTER_SANITIZE_NUMBER_FLOAT));
1069+
var_dump(filter_var($number, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
1070+
?>
1071+
]]>
1072+
</programlisting>
1073+
&example.outputs;
1074+
<screen>
1075+
<![CDATA[
1076+
string(4) "1234"
1077+
string(5) "12.34"
1078+
]]>
1079+
</screen>
1080+
</informalexample>
1081+
</warning>
10571082
</listitem>
10581083
</varlistentry>
10591084

0 commit comments

Comments
 (0)