Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Response.php

function Response::getHeader

Same name in this branch
  1. 11.1.x vendor/composer/composer/src/Composer/Util/Http/Response.php \Composer\Util\Http\Response::getHeader()

Return value

string|array|null The first header value if $first is true, an array of values otherwise

File

vendor/symfony/browser-kit/Response.php, line 75

Class

Response
@author Fabien Potencier <fabien@symfony.com>

Namespace

Symfony\Component\BrowserKit

Code

public function getHeader(string $header, bool $first = true) : string|array|null {
    $normalizedHeader = str_replace('-', '_', strtolower($header));
    foreach ($this->headers as $key => $value) {
        if (str_replace('-', '_', strtolower($key)) === $normalizedHeader) {
            if ($first) {
                return \is_array($value) ? \count($value) ? $value[0] : '' : $value;
            }
            return \is_array($value) ? $value : [
                $value,
            ];
        }
    }
    return $first ? null : [];
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal