Title: Headers::offsetGet
Published: March 29, 2023
Last modified: November 8, 2023

---

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

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wporg-requests-response-headers/offsetget/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/wporg-requests-response-headers/offsetget/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wporg-requests-response-headers/offsetget/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wporg-requests-response-headers/offsetget/?output_format=md#source)

[ Back to top](https://developer.wordpress.org/reference/classes/wporg-requests-response-headers/offsetget/?output_format=md#wp--skip-link--target)

Get the given header

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wporg-requests-response-headers/offsetget/?output_format=md#description)󠁿

Unlike [\WpOrg\Requests\Response\Headers::getValues()](https://developer.wordpress.org/reference/classes/WpOrgRequestsResponseHeaders/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](https://developer.wordpress.org/reference/classes/wporg-requests-response-headers/offsetget/?output_format=md#parameters)󠁿

 `$offset`stringrequired

Name of the header to retrieve.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wporg-requests-response-headers/offsetget/?output_format=md#return)󠁿

 string|null Header value

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wporg-requests-response-headers/offsetget/?output_format=md#source)󠁿

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

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

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

[View all references](https://developer.wordpress.org/reference/files/wp-includes/requests/src/response/headers.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/Requests/src/Response/Headers.php#L33)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/Requests/src/Response/Headers.php#L33-L43)

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwporg-requests-response-headers%2Foffsetget%2F)
before being able to contribute a note or feedback.