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

Breadcrumb

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

function MessageInterface::getHeaders

Retrieves all message header values.

The keys represent the header name as it will be sent over the wire, and each value is an array of strings associated with the header.

// Represent the headers as a string foreach ($message->getHeaders() as $name => $values) { echo $name . ": " . implode(", ", $values); }

// Emit headers iteratively: foreach ($message->getHeaders() as $name => $values) { foreach ($values as $value) { header(sprintf('%s: %s', $name, $value), false); } }

While header names are not case-sensitive, getHeaders() will preserve the exact case in which headers were originally specified.

Return value

string[][] Returns an associative array of the message's headers. Each key MUST be a header name, and each value MUST be an array of strings for that header.

File

vendor/psr/http-message/src/MessageInterface.php, line 68

Class

MessageInterface
HTTP messages consist of requests from a client to a server and responses from a server to a client. This interface defines the methods common to each.

Namespace

Psr\Http\Message

Code

public function getHeaders() : array;

API Navigation

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