Menu Riverview Church

GET_HEADERS

Fetches all the headers sent by the server in response to an HTTP request

SYNTAX

get_headers ( string $url [, int $format = 0 [, resource $context ]] ) : array

PARAMETERS

url

The target URL.

format

If the optional format parameter is set to non-zero, get_headers() parses the response and sets the array's keys.

context

A valid context resource created with stream_context_create().

RETURN

Returns an indexed or associative array with the headers, or FALSE on failure.

EXAMPLES

URL

Array
(
    [0] => HTTP/1.1 200 OK
    [1] => Server: myracloud
    [2] => Date: Sun, 25 Oct 2020 22:38:44 GMT
    [3] => Content-Type: text/html; charset=utf-8
    [4] => Connection: close
    [5] => Last-Modified: Sun, 25 Oct 2020 22:30:07 GMT
    [6] => Content-language: en
    [7] => X-Frame-Options: SAMEORIGIN
    [8] => Set-Cookie: COUNTRY=NA%2C198.71.228.76; expires=Sun, 01-Nov-2020 22:38:44 GMT; Max-Age=604800; path=/; domain=.php.net
    [9] => Set-Cookie: LAST_NEWS=1603665524; expires=Mon, 25-Oct-2021 22:38:44 GMT; Max-Age=31536000; path=/; domain=.php.net
    [10] => Link: <https://www.php.net/index>; rel=shorturl
    [11] => Expires: Sun, 25 Oct 2020 22:38:44 GMT
    [12] => Cache-Control: max-age=0
)

FORMAT

Array
(
    [0] => HTTP/1.1 200 OK
    [Date] => Sun, 25 Oct 2020 22:38:45 GMT
    [Server] => Apache
    [X-Powered-By] => PHP/7.4.9
    [Pragma] => no-cache
    [cache-control] => must-revalidate, no-cache, no-store, no-transform
    [expires] => 0
    [x-frame-options] => sameorigin
    [x-robots-tag] => noarchive, noimageindex
    [Upgrade] => h2,h2c
    [Connection] => Upgrade, close
    [Vary] => Accept-Encoding,User-Agent
    [Content-Type] => text/html; charset=utf-8
)

CONTEXT

Array
(
    [0] => HTTP/1.1 200 OK
    [Date] => Sun, 25 Oct 2020 22:38:45 GMT
    [Server] => Apache
    [X-Powered-By] => PHP/7.4.9
    [Pragma] => no-cache
    [cache-control] => must-revalidate, no-cache, no-store, no-transform
    [expires] => 0
    [x-frame-options] => sameorigin
    [x-robots-tag] => noarchive, noimageindex
    [Upgrade] => h2,h2c
    [Connection] => Upgrade, close
    [Vary] => User-Agent
    [Content-Type] => text/html; charset=utf-8
)

PHP