FILTER_SANITIZE_NUMBER_FLOAT 過濾器刪除浮點數中所有非法的字元。
此過濾器預設允許所有數字以及+ -
Name: "number_float"
ID-number: 520
可能的標誌:
FILTER_FLAG_ALLOW_FRACTION - 允許小數分隔符號(例如.)
FILTER_FLAG_ALLOW_THOUSAND - 允許千位分隔符號(例如,)
FILTER_FLAG_ALLOW_SCIENTIFIC - 允許科學記數法(如e 和E)
<?php$number="5-2f+3.3pp";var_dump(filter_var($number, FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION));?>
程式碼的輸出如下所示:
string(7) "5-2+3.3"