找回密码
 免费注册

php报错出现Warning: A non-numeric value encountered in解决方法

[复制链接]
发表于 2022-11-23 14:50:15 | 显示全部楼层 |阅读模式
php报错出现Warning: A non-numeric value encountered in解决方法

遇到这种php问题,应该在代码逻辑查看,为何会出现混合数值,检查哪里出错导致出现混合数值。
对于(+ - * / ** % << >> | & ^) 的运算,我们也可以加入转换类型方法,把错误的数值转换。

把类型转换下就可以。

举例:
  1. <?php
  2. error_reporting(E_ALL);
  3. ini_set('display_errors', 'on');

  4. $a = '123a';
  5. $b = 'b456';

  6. echo intval($a)+intval($b);
  7. ?>
复制代码
  1. $disan = (int)$jhy + (int)$jhe;
复制代码

QQ|Archiver|小黑屋|网站地图|深圳市金黑网络技术有限公司 ( 粤ICP备2021124338号|粤公网安备 44030702003689号 )

GMT+8, 2026-8-8 17:13 , Processed in 0.045038 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表