Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何显示网站';用PHP的头信息?_Php_Http Headers - Fatal编程技术网

如何显示网站';用PHP的头信息?

如何显示网站';用PHP的头信息?,php,http-headers,Php,Http Headers,如何使用php获取像此网页(以下)这样的标题信息 本网站 结果: HTTP Status for: "http://www.abc.com" The title is: "" Keywords: "" Description: "" HTTP/1.1 200 OK Date: Fri, 22 Feb 2013 12:00:56 GMT Server: Apache/2.2.3 (Debian) PHP/4.4.4-8+etch6 X-Powered-By: PHP/4.4.4-8+etch6

如何使用php获取像此网页(以下)这样的标题信息

本网站

结果:

HTTP Status for: "http://www.abc.com"
The title is: ""

Keywords: ""
Description: ""

HTTP/1.1 200 OK
Date: Fri, 22 Feb 2013 12:00:56 GMT
Server: Apache/2.2.3 (Debian) PHP/4.4.4-8+etch6
X-Powered-By: PHP/4.4.4-8+etch6
Keep-Alive: timeout=300
Connection: Keep-Alive
Content-Type: text/html

使用PHPs函数获取标题:

$headers = get_headers($url, 1);
见:

如果还需要元关键字和元描述,请使用:

您可以使用:

print_r(get_headers($url));

您可以使用PHP函数
get_header()。
此函数将返回一个包含所有标题字段的数组

有关更多信息,请参阅:

print_r(get_headers($url));