Answer the question
In order to leave comments, you need to log in
How to fix Trying to access array offset on value of type null?
Greetings!
After upgrading to PHP 7.4, a bug appeared that cannot be fixed.
If the $favorites_info value does not exist, it throws an error Trying to access array offset on value of type
null
$fav_id = $goods_id;
$favorites_model = model('favorites');
//Вы уже добавили этот товар в избранное
$favorites_info = $favorites_model->getOneFavorites(array(
'fav_id' => "$fav_id",
'fav_type' => 'goods',
'member_id' => session('member_id')
));
//$favorites_info = $favorites_info ?? ''; //я добавил этот код, но выдает ошибку Illegal string offset 'fav_id'
View::assign('favorites_info', $favorites_info);
{$favorites_info.fav_id}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question