我刚刚将我的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;
}
我的项目中有一些库在使用花括号来获取字符串内个别字符,有什么最好的方法可以解决语法问题?