W3cubDocs

/WordPress

Headers::offsetGet( string $offset ): string|null

Get the given header

Description

Unlike \WpOrg\Requests\Response\Headers::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.

Parameters

$offsetstringrequired
Name of the header to retrieve.

Return

string|null Header value

Source

public function offsetGet($offset) {
	if (is_string($offset)) {
		$offset = strtolower($offset);
	}

	if (!isset($this->data[$offset])) {
		return null;
	}

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

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wporg-requests-response-headers/offsetget