You are here

public function Request::getHeader in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-diactoros/src/Request.php \Zend\Diactoros\Request::getHeader()

Retrieves a message header value by the given case-insensitive name.

This method returns an array of all the header values of the given case-insensitive header name.

If the header does not appear in the message, this method MUST return an empty array.

Parameters

string $header Case-insensitive header field name.:

Return value

string[] An array of string values as provided for the given header. If the header does not appear in the message, this method MUST return an empty array.

Overrides MessageTrait::getHeader

File

vendor/zendframework/zend-diactoros/src/Request.php, line 56

Class

Request
HTTP Request encapsulation

Namespace

Zend\Diactoros

Code

public function getHeader($header) {
  if (!$this
    ->hasHeader($header)) {
    if (strtolower($header) === 'host' && ($this->uri && $this->uri
      ->getHost())) {
      return [
        $this
          ->getHostFromUri(),
      ];
    }
    return [];
  }
  $header = $this->headerNames[strtolower($header)];
  $value = $this->headers[$header];
  $value = is_array($value) ? $value : [
    $value,
  ];
  return $value;
}