时间:2021-07-01 10:21:17 帮助过:13人阅读
php保留两位小数例子 四舍五入
1.number_format
$number = 1234.5678;
$nombre_format_francais = number_format($number, 2, ,, );
// 1 234,57
$english_format_number = number_format($number, 2, ., );
// 1234.57
2.round
$number = 1234.5678;
echo round($number ,2);
//1234.57
3.sprintf
$formatted = sprintf ("%s有¥%01.2f。",$name, $money);
echo $formatted;
//张三有¥123.10。
http://www.bkjia.com/PHPjc/478833.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478833.htmlTechArticleJS保留两位小数例子 四舍五入使用函数toFixed() html head /head script language="javascript" document.write("h1JS保留两位小数例子/h1br"); var a=2.1512131231231...