“PHP Warning: number_format() expects parameter 1 to be double, string given in C:inetpubwwwrootincludeslib_common.php on line 973”![](https://images0.cnblogs.com/blog/69929/201508/111550441608112.png)
![](https://images0.cnblogs.com/blog/69929/201508/111550446145040.png)
![](https://images0.cnblogs.com/blog/69929/201508/111550441608112.png)
![](https://images0.cnblogs.com/blog/69929/201508/111550446145040.png)
在查看源码的时候并没有发现问题,然后就把$price的打印了出来也没有发现问题,此时$price的值为:string(4) "0.10"
![](https://images0.cnblogs.com/blog/69929/201508/111550463484010.png)
最后在网络上了解到解决方案:
先将值转换成数值类型,然后再使用number_format方法,第938行
但奇怪的是在number_format方法里直接使用string类型并没有任何问题,即使string的值无法完全转换成数值类型也不会出错
如下面的"2s5.689sf"直接转换成2.00,且没有出现问题
![](https://images0.cnblogs.com/blog/69929/201508/111550468485923.png)
![](https://images0.cnblogs.com/blog/69929/201508/111550472235109.png)
参考: