PHP报错 Trying to access array offset on value of type null

于 2024-05-17 发布 阅读量1503  

Trying to access array offset on value of type null

报错原因是: 试图访问null类型值的数组偏移量 也就是说数组中null值导致了报错

php7.4版本会报这个错误

解决方案

1、将低php版本 7.4以下

2、加判断将数据中的null值改为0

$a =null;
empty($a) ? $a : 0; 
//如何是数组可以循环处理

3、在指定文件中屏蔽错误

error_reporting (E_ERROR);