1 $num = 10.4567; 2 3 //第一种:利用round()对浮点数进行四舍五入 4 echo round($num,2); //10.46 5 6 //第二种:利用sprintf格式化字符串 7 $format_num = sprintf("%.2f",$num); 8 echo $format_num; //10.46 9 10 //第三种:利用千位分组来格式化数字的函数number_format() 11 echo number_format($num, 2); //10.46 12 //或者如下 13 echo number_format($num, 2, '.', ''); //10/46