<?php $num = 1234.567; $res = sprintf('%.1f',$num); echo $res; ?> 输出结果:1234.5 若保存两位小数,则:sprintf('%.2f',$num);