yii\web\HeaderCollection::get PHP Method

get() public method

Returns the named header(s).
public get ( string $name, mixed $default = null, boolean $first = true ) : string | array
$name string the name of the header to return
$default mixed the value to return in case the named header does not exist
$first boolean whether to only return the first header of the specified name. If false, all headers of the specified name will be returned.
return string | array the named header(s). If `$first` is true, a string will be returned; If `$first` is false, an array will be returned.
    public function get($name, $default = null, $first = true)
    {
        $name = strtolower($name);
        if (isset($this->_headers[$name])) {
            return $first ? reset($this->_headers[$name]) : $this->_headers[$name];
        } else {
            return $default;
        }
    }

Usage Example

コード例 #1
0
 /**
  * @return bool
  */
 private function checkHeaders()
 {
     if (!isset($this->currentParams['headers'])) {
         return true;
     }
     $originalStructure = $this->currentParams['headers'];
     /**
      * if token validator is active
      */
     foreach ($originalStructure as $header) {
         if (!$this->requestHeaders->get($header)) {
             throw new InvalidParamException(\Yii::t('system', 'Header \'{0}\' is empty', [$header]), 406);
         }
     }
     return true;
 }
All Usage Examples Of yii\web\HeaderCollection::get