区分大小写字典{}

在本文中

不区分大小写的字典,适用于HTTP标头

方法

姓名描述
区分大小写字典::__construct创建不区分大小写的字典。
区分大小写字典::getAll将标头作为数组获取
区分大小写Dictionary::getIterator
区分大小写Dictionary::offset存在
区分大小写Dictionary::offsetGet
区分大小写Dictionary::offsetSet
区分大小写Dictionary::offsetUnset——

来源

类CaseInsensitiveDictionary实现ArrayAccess、IteratorAggregate{/***实际物料数据**@var数组*/受保护的$data=[];/***创建不区分大小写的字典。**@param array$data Dictionary/map转换为区分大小写*/公共函数__construct(数组$data=[]){foreach($data作为$offset=>$value){$this->offsetSet($offset,$value);}}/***检查给定项是否存在**@param string$offset项键*@return boolean项目是否存在?*/#[返回类型更改]公共函数offsetExists($offset){if(is_string($offset)){$offset=strtolower($offset);}返回isset($this->数据[$offset]);}/***获取项目的值**@param string$offset项键*@return string | null项目值(如果项目键不存在,则为null)*/#[返回类型更改]公共函数offsetGet($offset){if(is_string($offset)){$offset=strtolower($offset);}if(!isset($this->data[$offset]){返回null;}返回$this->data[$offset];}/***设置给定项**@param string$offset项目名称*@param string$value项目值**@throws\WpOrg\Requests\Exception尝试将字典用作列表(`invalidset`)*/#[返回类型更改]公共函数offsetSet($offset,$value){if($offset===null){throw new Exception(“Object is a dictionary,not a list”,“invalidset”);}if(is_string($offset)){$offset=strtolower($offset);}$this->data[$offset]=$value;}/***取消设置给定的标头**@param string$offset要取消设置的项的键。*/#[返回类型更改]公共函数offsetUnset($offset){if(is_string($offset)){$offset=strtolower($offset);}unset($this->data[$offset]);}/***获取数据的迭代器**@return\ArrayIterator*/#[返回类型更改]公共函数getIterator(){返回新的ArrayIterator($this->data);}/***将标头作为数组获取**@return数组头数据*/公共函数getAll(){返回$this->数据;}}

用户贡献的笔记

你必须登录在能够发表注释或反馈之前。