Oktay
Oktay

Reputation: 81

Get website header with IP

I want to get the header from a website with the IP address.

I used get_header() but this only works with URL! Are there other ways to do this? Without using gethostbyaddre.

Upvotes: 2

Views: 383

Answers (4)

Álvaro González
Álvaro González

Reputation: 146350

  • You have an IP address, e.g.: 127.0.0.1

  • You want to use get_headers() (with trailing s)

  • ...but get_headers() expects a URL:

    array get_headers ( string $url [, int $format = 0 ] )
    
  • You add http:// and you get a URL: http://127.0.0.1—voilá!

Upvotes: 2

Guido Hendriks
Guido Hendriks

Reputation: 5776

You can actually use an IP. Since there's no code, I can't tell where you're going wrong. But I can tell how it should be done:

$url = 'http://173.194.65.101/';
$headers = get_headers($url);
print_r($headers);

Upvotes: 5

David Ansermot
David Ansermot

Reputation: 6112

You can make a cUrl call than analyse and extract the headers from the server's reponse.

Upvotes: 0

Karthick Kumar
Karthick Kumar

Reputation: 2361

use $_SERVER['REMOTE_ADDR'] to get the ip address.

Upvotes: 0

Related Questions