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

Breadcrumb

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

function HeaderBag::__toString

Returns the headers as a string.

File

vendor/symfony/http-foundation/HeaderBag.php, line 42

Class

HeaderBag
HeaderBag is a container for HTTP headers.

Namespace

Symfony\Component\HttpFoundation

Code

public function __toString() : string {
    if (!($headers = $this->all())) {
        return '';
    }
    ksort($headers);
    $max = max(array_map('strlen', array_keys($headers))) + 1;
    $content = '';
    foreach ($headers as $name => $values) {
        $name = ucwords($name, '-');
        foreach ($values as $value) {
            $content .= \sprintf("%-{$max}s %s\r\n", $name . ':', $value);
        }
    }
    return $content;
}

API Navigation

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