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

    echo "<pre>";
    print_r(get_headers("", true));
    echo "</pre>";  


comming soon.....

See also :  Codeigniter error: Call to undefined function mysql_pconnect()

Leave a Reply

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