PHP FILTER_SANITIZE_NUMBER_FLOAT 过滤器

PHP 教程 · 2019-01-25 21:27:29

定义和用法

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"


点击查看所有 PHP 教程 文章: https://www.codercto.com/courses/l/5.html

查看所有标签

Uberland

Uberland

Alex Rosenblat / University of California Press / 2018-11-19 / GBP 21.00

Silicon Valley technology is transforming the way we work, and Uber is leading the charge. An American startup that promised to deliver entrepreneurship for the masses through its technology, Uber ins......一起来看看 《Uberland》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

html转js在线工具
html转js在线工具

html转js在线工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具