PHPget_headers () function details _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
PHPget_headers () function details. Get_headers: Send the server response HTTP request get_headers (string url [link format]) get_headers () to return the server HTTP request in an array. If the execution fails, FALSE and get_headers will be returned: Send the server to respond to the HTTP request
Get_headers (string url [link format])
Get_headers () returns the HTTP request of the server as an array. If the execution fails, FALSE and an error level E_WARNING are returned.
The optional parameter is set to 1. get_headers () can analyze the system response speed and the keys in the array.

Note: To use this function, you must use allow_url_fopen = On in php. ini.

Example:
$ Url = http://www.ite5e.com;
Print_r (get_headers ($ url ));
Print_r (get_headers ($ url, 1 ));
?>

Print result:
Array
(
[0] => HTTP/1.1 200 OK
[1] => Connection: close
[2] => Date: Tue, 16 Nov 2010 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, 16 Nov 2010 09:19:13 GMT
[7] => Accept-Ranges: bytes
[8] => ETag: "50d16c556f85cb1:b1f76"
[9] => Server: Microsoft-IIS/6.0
[10] => X-Powered-By: ASP.NET
)
Array
(
[0] => HTTP/1.1 200 OK
[Connection] => close
[Date] => Tue, 16 Nov 2010 09:48:21 GMT
[Content-Length] => 52708
[Content-Type] => text/html
[Content-Location] => http://www.ite5e.com/index.html
[Last-Modified] => Tue, 16 Nov 2010 09:19:13 GMT
[Accept-Ranges] => bytes
[ETag] => "50d16c556f85cb1:b1f76"
[Server] => Microsoft-IIS/6.0
[X-Powered-By] => ASP.NET
)

Response get_headers (string url [link format]) get_headers () returns the server HTTP request in the form of an array. If the execution fails, FALSE and... are returned...

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.