pirpirim
pirpirim

Reputation: 93

How to display a website's header information with PHP?

How can I get the Header Informations like this web page (below) with using php

This web site Check website HTTP Server Header Information

Result:

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

Upvotes: 3

Views: 4352

Answers (3)

insertusernamehere
insertusernamehere

Reputation: 23580

Use PHPs function get_headers:

$headers = get_headers($url, 1);

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

If you also want the meta keywords and meta description use get_meta_tags():

$tags = get_meta_tags($url);

Upvotes: 4

Tjoene
Tjoene

Reputation: 350

You can use the PHP function get_header();. This function will return an array with all the header fields.

For more information see: http://php.net/manual/en/function.get-headers.php

Upvotes: 3

user2095686
user2095686

Reputation:

You could use:

print_r(get_headers($url));

Upvotes: 2

Related Questions