dq62957 2014-07-16 06:33
浏览 61
已采纳

echo可以指定一个浮点数吗?

I can do this using printf()

printf ("Total amount of order is %.2f", $total);

Can I do the same using echo, or I have to use printf()?

  • 写回答

3条回答 默认 最新

  • drpph80800 2014-07-16 06:43
    关注

    You can use this..

    $total= 100.123;
    echo "Total amount of order is ". round($total, 2);
    

    Output:

    Total amount of order is 100.12
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?