如何限制显示小数点后的数字

问题描述 投票:0回答:2
php html web-applications
2个回答
0
投票

定义小数值精度的方法之一是四舍五入。您可以使用

round($number, $precision)

按照你的例子,它看起来像这样:

round($calvat+$itemtotal+$servicetotal-($discount+$pdiscount), 2);

https://www.php.net/manual/en/function.round.php


0
投票

试试这个。 $值= 3.142327; echo sprintf("%.2f", $value);

© www.soinside.com 2019 - 2024. All rights reserved.