Home > Backend Development > PHP Tutorial > Detailed explanation of PHP get_headers() function_PHP tutorial

Detailed explanation of PHP get_headers() function_PHP tutorial

WBOY
Release: 2016-07-13 17:42:18
Original
2528 people have browsed it

get_headers: Send the server response to the HTTP request
get_headers (string url [link format])
get_headers() returns the server HTTP request in the form of an array. If execution fails, FALSE and an error level E_WARNING will be returned.
The optional parameter is set to 1, get_headers() can analyze the response speed of the system and set the keys in the array.

Note
: To use this function, you need to set allow_url_fopen = On in php.ini to use it.

The example is as follows:
$url = http://www.ite5e.com;
print_r(get_headers($url));
print_r(get_headers($url, 1));
?>

Print result:
Array

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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486068.htmlTechArticleget_headers: Send server response to HTTP request get_headers (string url [link format]) get_headers() in the form of an array Returns the server HTTP request. If the execution fails, FALSE and one will be returned...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template