php get_headers

The get_headers() function returns all the headers sent by the server for an HTTP request.

PHP get_headers() Syntax

[php]
get_headers(string $url , int $format = 0 , resource $context = ? );
[/php]

  1. string $url | required : targeted URL . However the URL must be valid otherwise an error will occur.
  2. int $format = 0 | Optional : Associative Array is returned on passing non – zero value. Otherwise an Indexed Array of headers is returned.
  3. resource $context = ? , optional : valid context resource created by stream_context_create() .
  4. Return Value: It returns an indexed or associative array of headers, failing which false.

PHP get_headers() Example

File : php_get_headers.php
[php]
“; print_r(get_headers(“https://www.itsolutionstuck.com”)); print_r(get_headers(“https://www.itsolutionstuck.com”, true)); echo “

“;
?>
[/php]

Result:
[php]
comming soon…..
[/php]

See also :  Support for PHP frameworks in the CodeLobster IDE

Leave a Comment