Requests_Response_Headers::offsetGet() WordPress Method

The Requests_Response_Headers::offsetGet() method is used to get the value of a header from a Response object. The method takes one argument, the name of the header to retrieve, and returns the value of the header.

Requests_Response_Headers::offsetGet( string $key ) #

Get the given header


Description

Unlike self::getValues(), this returns a string. If there are multiple values, it concatenates them with a comma as per RFC2616.

Avoid using this where commas may be used unquoted in values, such as Set-Cookie headers.


Top ↑

Parameters

$key

(string)(Required)


Top ↑

Return

(string|null) Header value


Top ↑

Source

File: wp-includes/Requests/Response/Headers.php

	public function offsetGet($key) {
		$key = strtolower($key);
		if (!isset($this->data[$key])) {
			return null;
		}

		return $this->flatten($this->data[$key]);
	}

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.