PHP7.3 报错: A non well formed numeric value encountered

从PHP5.6 升级为PHP7.3 后,某接口报错: A non well formed numeric value encountered

 

看了下,是把字符串和数字放在一起做加减乘除计算,会导致报错。。。代码如下

 

$commissionLevel1 = (float)($commissionSetting->level1 / 100);//$commissionSetting->level1 是个字符串: “20%”


改为

$commissionLevel1 = (float)$commissionSetting->level1 / 100;

先将字符串转化为浮点数字,然后再计算即可

看来PHP7.3 比 PHP5.6 严格了



上一篇:工业互联网平台 GE predix


下一篇:TP5.1出现A non well formed numeric value encountered问题