You are here

public function MessageTrait::getHeader in Zircon Profile 8

Same name in this branch
  1. 8 vendor/zendframework/zend-diactoros/src/MessageTrait.php \Zend\Diactoros\MessageTrait::getHeader()
  2. 8 vendor/guzzlehttp/psr7/src/MessageTrait.php \GuzzleHttp\Psr7\MessageTrait::getHeader()
Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-diactoros/src/MessageTrait.php \Zend\Diactoros\MessageTrait::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.

1 call to MessageTrait::getHeader()
MessageTrait::getHeaderLine in vendor/zendframework/zend-diactoros/src/MessageTrait.php
Retrieves a comma-separated string of the values for a single header.
1 method overrides MessageTrait::getHeader()
Request::getHeader in vendor/zendframework/zend-diactoros/src/Request.php
Retrieves a message header value by the given case-insensitive name.

File

vendor/zendframework/zend-diactoros/src/MessageTrait.php, line 131

Class

MessageTrait
Trait implementing the various methods defined in MessageInterface.

Namespace

Zend\Diactoros

Code

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