当前位置:首页运维笔记php7.4报错:Trying to access array offset on value of type null

php7.4报错:Trying to access array offset on value of type null

php7.4报错:Trying to access array offset on value of type nullphp升级后的7.4版本性能真的好到爆炸,可是依然会有个别的兼容性问题,比如Php-fpm的新选项ProtectHome会导致经典的File not found错误,再是Php解释器会对null类型的下标访问直接报错Trying to access array offset on value of type null;

那么对于出现Trying to access array offset on value of type null报错的解决方法其实也很简单,无非就是避免数组出现null就好了,那么我们可以在之前加个判断,比如$tempres[‘p_name’]会出现null,改写之后的代码

1
2
3
4
5
6

if(!empty($tempres)){

$productname= $tempres[‘p_name’];
}else{
$productname= ”;
}

是不是就完美解决了呢?

温馨提示:

文章标题:php7.4报错:Trying to access array offset on value of type null

文章链接:https://p1e.cn/html/2388.html

更新时间:2021年02月04日

本站大部分内容均收集于网络!若内容若侵犯到您的权益,请发送邮件至:815494#qq.com我们将第一时间处理! 资源所需价格并非资源售卖价格,是收集、整理、编辑详情以及本站运营的适当补贴,并且本站不提供任何免费技术支持。 所有资源仅限于参考和学习,版权归原作者所有。

给TA打赏
共{{data.count}}人
人已打赏
运维笔记

dedecms v5.7 qrcode二维码XSS跨站脚本漏洞

2021-2-3 14:48:00

运维笔记

WordPress升级更新方法详解

2021-2-4 9:40:38

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索