尝试在PHP 7.4中访问类型为bool的值的数组偏移量 [英] Trying to access array offset on value of type bool in PHP 7.4
本文介绍了尝试在PHP 7.4中访问类型为bool的值的数组偏移量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚将服务器的PHP版本升级到PHP 7.4.1,现在出现此错误:
Notice: Trying to access array offset on value of type bool in
I just upgraded my server's PHP version to PHP 7.4.1 and now getting this error :
Notice: Trying to access array offset on value of type bool in
public static function read($id)
{
$Row = MySQL::query("SELECT `Data` FROM `cb_sessions` WHERE `SessionID` = '$id'", TRUE);
# http://php.net/manual/en/function.session-start.php#120589
//check to see if $session_data is null before returning (CRITICAL)
if(is_null($Row['Data']))
{
$session_data = '';
}
else
{
$session_data = $Row['Data'];
}
return $session_data;
}
PHP 7.4的修复程序是什么?
What is the fix for PHP 7.4 ?
推荐答案
易于使用PHP ??
isset运算符
Easy with Php ??
isset operator
return $Row['Data'] ?? 'default value';
或者您可以使用
$Row['Data']??='default value';
return $Row['Data'];
这篇关于尝试在PHP 7.4中访问类型为bool的值的数组偏移量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文