PHP注意:未定义的偏移量:1-GraphRawResponse.PHP
我收到以下PHP错误:PHP注意:未定义的偏移量:1-GraphRawResponse.PHP,php,Php,我收到以下PHP错误: Undefined offset: 1 代码是: public function setHttpResponseCodeFromHeader($rawResponseHeader) { preg_match('|HTTP/\d\.\d\s+(\d+)\s+.*|', $rawResponseHeader, $match); $this->httpResponseCode = (int)$match[1]; } 如何解决此错误?在访问数组$matc
Undefined offset: 1
代码是:
public function setHttpResponseCodeFromHeader($rawResponseHeader)
{
preg_match('|HTTP/\d\.\d\s+(\d+)\s+.*|', $rawResponseHeader, $match);
$this->httpResponseCode = (int)$match[1];
}
如何解决此错误?在访问数组$match之前是否初始化了它? 在访问$match之前,请尝试此操作
$match = [];
//or
$match = array();
谢谢。使用$match=array修复了该问题;你给我写了$math,编辑它!谢谢!不,问题:我已经编辑了变量