PHP floor() 函数

PHP 教程 · 2019-01-26 21:57:19

实例

向下舍入为最接近的整数:

<?php
echo(floor(0.60) . "<br>");
echo(floor(0.40) . "<br>");
echo(floor(5) . "<br>");
echo(floor(5.1) . "<br>");
echo(floor(-5.1) . "<br>");
echo(floor(-5.9));
?>

定义和用法

floor() 函数向下舍入为最接近的整数。

提示:如需向上舍入为最接近的整数,请查看 ceil() 函数。

提示:如需对浮点数进行四舍五入,请查看 round() 函数。

语法

floor(number);

参数 描述
number 必需。规定需向下取整的值。

技术细节

返回值: 向下舍入的最接近的整数值。
返回类型: Float
PHP 版本: 4+

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

查看所有标签

The Art of Computer Programming, Volumes 1-3 Boxed Set

The Art of Computer Programming, Volumes 1-3 Boxed Set

Donald E. Knuth / Addison-Wesley Professional / 1998-10-15 / USD 199.99

This multivolume work is widely recognized as the definitive description of classical computer science. The first three volumes have for decades been an invaluable resource in programming theory and p......一起来看看 《The Art of Computer Programming, Volumes 1-3 Boxed Set》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具