PHPize Online / SQLize Online
A A A

Donate Popular

get_headers

Tags: PHP 5.x PHP 7.x PHP 8.x

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

Description

get_headers(
    string $url,
bool $associative = false,
?resource $context = null
): array|false
get_headers() returns an array with the headers sent by the server in response to a HTTP request.

Parameters

url
The URL to fetch the headers from.
associative
If set to true, the array returned will use the header names as keys. If set to false, the array will use numeric keys, starting at 0.
context
A valid context resource created with stream_context_create().

Return Values

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