<?php
// 示例代码:四舍五入
// 使用 round() 函数进行四舍五入
$number = 3.75;
$rounded_number = round($number); // 结果为 4
echo "原始数字: $number, 四舍五入后: $rounded_number\n";
// 指定小数位数进行四舍五入
$number_with_precision = 3.756;
$rounded_with_precision = round($number_with_precision, 2); // 结果为 3.76
echo "原始数字: $number_with_precision, 四舍五入到两位小数后: $rounded_with_precision\n";
?>
round()
函数用于对浮点数进行四舍五入。下一篇:php trim函数
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站