3

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

本网站检查网站 HTTP Server Header 信息

结果:

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
4

3 回答 3

4

使用 PHP 函数get_headers

$headers = get_headers($url, 1);

见: http: //php.net/manual/en/function.get-headers.php

如果您还想要元关键字元描述,请使用get_meta_tags()

$tags = get_meta_tags($url);
于 2013-02-22T11:41:42.380 回答
3

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

有关更多信息,请参阅: http: //php.net/manual/en/function.get-headers.php

于 2013-02-22T11:42:24.530 回答
2

你可以使用:

print_r(get_headers($url));
于 2013-02-22T11:42:12.573 回答