我刚刚将我的php版本更新为7.4,我注意到出现了以下错误:
不推荐使用带大括号的数组和字符串偏移量访问语法
以下是触发上述错误的部分代码:
public function getRecordID(string $zoneID, string $type = '', string $name = ''): string
{
$records = $this->listRecords($zoneID, $type, $name);
if (isset($records->result{0}->id)) {
return $records->result{0}->id;
}
return false;
}
在我的项目中,很少有库使用大括号来获取字符串中的单个字符,更改语法问题的最好方法是什么?