You are here

public static function ServerRequestFactory::getHeader in Zircon Profile 8

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

Search for a header value.

Does a case-insensitive search for a matching header.

If found, it is returned as a string, using comma concatenation.

If not, the $default is returned.

Parameters

string $header:

array $headers:

mixed $default:

Return value

string

2 calls to ServerRequestFactory::getHeader()
ServerRequestFactory::marshalHostAndPortFromHeaders in vendor/zendframework/zend-diactoros/src/ServerRequestFactory.php
Marshal the host and port from HTTP headers and/or the PHP environment
ServerRequestFactory::marshalUriFromServer in vendor/zendframework/zend-diactoros/src/ServerRequestFactory.php
Marshal the URI from the $_SERVER array and headers

File

vendor/zendframework/zend-diactoros/src/ServerRequestFactory.php, line 111

Class

ServerRequestFactory
Class for marshaling a request object from the current PHP environment.

Namespace

Zend\Diactoros

Code

public static function getHeader($header, array $headers, $default = null) {
  $header = strtolower($header);
  $headers = array_change_key_case($headers, CASE_LOWER);
  if (array_key_exists($header, $headers)) {
    $value = is_array($headers[$header]) ? implode(', ', $headers[$header]) : $headers[$header];
    return $value;
  }
  return $default;
}