get_headers

PHP 5, PHP 7, PHP 8
get_headers - Fetches all the headers sent by the server in response to an HTTP request
Manual
Code Examples

get_headers( string$url, [bool$associative = false], [resource|null$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 target URL.

associative

If the optional associative parameter is set to true, get_headers parses the response and sets the array's keys.

context

A valid context resource created with stream_context_create, or null to use the default context.

Return Values

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

Changelog

Version Description
8.0.0 The associative has been changed from int to bool.
7.1.0 The context parameter was added.

Related Functions

Example of get_headers

Show all examples for get_headers

PHP Version:


Function get_headers:

URLs Functions

Most used PHP functions