在PHP中乘以float和int [英] Multiplying a float and int in PHP
本文介绍了在PHP中乘以float和int的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
1.00 * 5 = 0。
我希望输出为5.00
如何使用php?
解决方案
我想你正在寻找 number_format
:
number_format(1.00 * 5,2); //5.00
在此处查看: http://codepad.viper-7.com/mSFpqH
Iam a beginner to php. When i tried to multiply a integer value with a decimal ,get the results as follows.
1.00 * 5 = 0 . I want the output as 5.00 How is can be done using php?
解决方案
I think you're looking for number_format
:
number_format(1.00 * 5, 2); // "5.00"
See it here in action: http://codepad.viper-7.com/mSFpqH
这篇关于在PHP中乘以float和int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文