php get_headers

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

PHP get_headers() Syntax

get_headers(string $url , int $format = 0 , resource $context = ? );

  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 	
    echo "<pre>";
    print_r(get_headers("https://www.itsolutionstuck.com"));
    print_r(get_headers("https://www.itsolutionstuck.com", true));
    echo "</pre>";  
?>

Result:

comming soon.....

See also :  Advantages of php - Top 10 Fundamental PHP Advantages And Disadvantages

Leave a Reply

Your email address will not be published. Required fields are marked *