PHP get_headers function Use method to parse what the header means PHP header kernel headers

Source: Internet
Author: User
Tags php example
In PHP development, we often need to get the server information sent in the HTTP request, this article through a simple PHP example of the Get_headers function to obtain information about the server.

Get_headers () is a PHP system-level function that returns an array containing the headers sent by the server in response to an HTTP request. If it fails, it returns false and emits an e_warning level error message (which can be used to determine if the remote file exists).

function definition

Array get_headers (string $url [, int $format = 0])

Parameters

URL Destination URL

Format if the optional format parameter is set to 1, Get_headers () parses the corresponding information and sets the array's key name.

Example

 
  

The output of the above routines is similar to the following:

Array (    [0] = http/1.1 [    1] = Date:sat, May 2004 12:28:13 GMT    [2] = server:apache/1.3.27 (Unix)  (Red-hat/linux)    [3] = last-modified:wed, Jan 2003 23:11:55 GMT    [4] = ETag: "3f80f-1b6-3e1cb03b"    [5] = = Accept-range S:bytes    [6] = content-length:438    [7] = Connection:close    [8] = content-type:text/html) Array ( C10/>[0] = http/1.1    [Date] + Sat, May 2004 12:28:14 GMT    [Server] + apache/1.3.27 (Unix) 
   (Red-hat/linux)    [last-modified] = Wed, Jan 2003 23:11:55 GMT    [ETag] = "3f80f-1b6-3e1cb03b"    [accept-ranges] = bytes    [Content-length] = 438    [Connection] = Close    [Content-type] = text/html)

The above introduces the use of get_headers function in PHP parsing, including the headers aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.