我刚刚升级我的服务器的PHP版本到PHP 7.4.1,现在得到这个错误:注意:尝试访问中bool类型值的数组偏移量
if ($info['msg'] == CURLMSG_DONE) {
$channel = $info['handle'];
$page = array_search($channel, $this->pages);
$this->pages[$page] = curl_multi_getcontent($channel);
$this->multiHandlingRemove($channel);
curl_close($channel);
}
PHP 7.4的修复程序是什么?
1条答案
按热度按时间pdkcd3nj1#
出现错误的原因是
array_search
将在未找到任何内容时返回false
,并且布尔值不能用作数组偏移量(也称为数组索引)。这表明您的脚本在某些场景中可能已经产生了不希望的结果,您需要检查是否没有返回false:
这里有一个稍微改进的版本,为了咯咯地笑:
在这里,它是一行程序,因为我喜欢它(不要使用它,它在任何意义上都不优雅):