PHP get_headers () function _php Tutorial

Source: Internet
Author: User
Get_headers: The sending server responds to HTTP requests
Get_headers (string url[link format])
Get_headers () returns the server HTTP request in the form of an array. If execution fails, it will return false and an error in the horizontal e_warning ".
The optional parameter is set to 1,get_headers () to analyze the system's response speed and the keys in the set array.

Note
: Use this function to use Allow_url_fopen = on in php.ini.

examples are as follows:
$url = http://www.ite5e.com;
Print_r (Get_headers ($url));
Print_r (Get_headers ($url, 1));
?>

Print Results:
Array
(
[0] = = http/1.1-OK
[1] = Connection:close
[2] = Date:tue, 09:48:20 GMT
[3] = content-length:52708
[4] = content-type:text/html
[5] = content-location:http://www.ite5e.com/index.html
[6] = Last-modified:tue, 09:19:13 GMT
[7] = Accept-ranges:bytes
[8] = ETag: "50d16c556f85cb1:b1f76"
[9] = server:microsoft-iis/6.0
[Ten] = X-powered-by:asp.net
)
Array
(
[0] = = http/1.1-OK
[Connection] = Close
[Date] = Tue, 09:48:21 GMT
[Content-length] = 52708
[Content-type] = text/html
[Content-location] = http://www.ite5e.com/index.html
[Last-modified] = Tue, 09:19:13 GMT
[Accept-ranges] = bytes
[ETag] = "50d16c556f85cb1:b1f76"
[Server] = microsoft-iis/6.0
[x-powered-by] = ASP.
)

http://www.bkjia.com/PHPjc/486068.html www.bkjia.com true http://www.bkjia.com/PHPjc/486068.html techarticle Get_headers: The sending server responds to HTTP request get_headers (string url[link format]) get_headers () returns the server HTTP request as an array. If execution fails, it will return false and a ...

  • 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.