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: Mon, 25 Jan 2021 23:40:50 GMT
[3] => Content-Type: text/html; charset=utf-8
[4] => Connection: close
[5] => Last-Modified: Mon, 25 Jan 2021 23:30:05 GMT
[6] => Content-language: en
[7] => X-Frame-Options: SAMEORIGIN
[8] => Set-Cookie: COUNTRY=NA%2C198.71.228.76; expires=Mon, 01-Feb-2021 23:40:50 GMT; Max-Age=604800; path=/; domain=.php.net
[9] => Set-Cookie: LAST_NEWS=1611618050; expires=Tue, 25-Jan-2022 23:40:50 GMT; Max-Age=31536000; path=/; domain=.php.net
[10] => Link: <https://www.php.net/index>; rel=shorturl
[11] => Expires: Mon, 25 Jan 2021 23:40:50 GMT
[12] => Cache-Control: max-age=0
)
FORMAT
Array
(
[0] => HTTP/1.1 200 OK
[Date] => Mon, 25 Jan 2021 23:40:50 GMT
[Server] => Apache
[X-Powered-By] => PHP/7.4.11
[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] => Mon, 25 Jan 2021 23:40:50 GMT
[Server] => Apache
[X-Powered-By] => PHP/7.4.11
[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
)