blog

当前位置:首页>文章中心>blog
Warning: number_format() expects parameter 1 to be double, string given in /Volumes/Data/xiaoniba/ww
blog 2016-02-03 1 阅读

Warning: number_format() expects parameter 1 to be double, string given in /Volumes/Data/xiaoniba/ww

小泥巴 小泥吧科技 2016-02-03
将includeslib_common.php 的957~959行: else { $price = number_format($price, 2, '.', ''); } 修改为 else { if(!$price){ $price = 0; } $price = number_format($price, 2, '.', ''); } 即可。原因是配送插件里面的免费额度为0,ec本身的bug导致了$price的值为空值,直接调用number_format出现了错误。 赞成lz分析的原因,确实是因为免费额度获取的问题,在PHP5.3上报错 但获取到的应该是一个字符串,所以出错,应该这样改: function price_format($price, $change_price = true) { $price = 0 + $price;//添加这一行,转换成数值 -------------------------------------------------------------------------------------------------------------- 上面为论坛网友分析原因和解决办法。 我直接在 includeslib_common.php中的 priceformat()【格式化商品价格函数】中 加一句
$price = (float)$price; //强制转换$price的数据类型。这样是不是优雅点,萌萌哒
相关标签:

发表评论:

评论记录:

未查询到任何数据!
QQ咨询
回电话
回拨通话

我们稍后回拨您的电话

座机请加区号

微信联系
微信扫一扫
微信二维码

扫码加微信