PHP floor()函数

PHP floor()函数

PHP floor()函数是一个数学函数,用于向下取整。它返回最接近的小于等于参数的整数值(以浮点数形式)。

语法

    float floor ( float $value ); 
参数 描述 必填/可选
number 用于向下取整的数字值 必填

示例1

<?php
nos=3.3;
echo "Your number is :".nos;
echo "<br>"."By using 'floor()' function your value is:".(floor($nos)); // 3  
?>

输出:

Your number is :3.3
By using 'floor()' function your value is:3

示例2

<?php
nos=7.333;
echo "Your number is :".nos;
echo "<br>"."By using 'floor()' function your value is:".(floor($nos)); 
?>

输出:

Your number is :7.333
By using 'floor()' function your value is:7

示例3

<?php
nos=-4.8;
echo "Your number is :".nos;
echo "<br>"."By using 'floor()' function your value is:".(floor($nos)); 
?>

输出:

Your number is :-4.8
By using 'floor()' function your value is:-5

示例4

<?php
nos=(-0.60);
echo "Your number is :".nos;
echo "<br>"."By using 'floor()' function your value is:".(floor($nos)); 
?>

输出:

Your number is :-0.6
By using 'floor()' function your value is:-1

Camera课程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

办公软件教程

Linux教程

计算机教程

大数据教程

开发工具教程