2

I am checking current hosting IP of websites using

$ip = gethostbyname('domainname.com');

It Returns IP address of websites working well but for some domains it returns back the domain name

$ip = gethostbyname('domainname.com');

Returns:

domianname.com

Peyman Mohamadpour
  • 17,954
  • 24
  • 89
  • 100
Sarjerao Ghadage
  • 1,420
  • 16
  • 31
  • 1
    It returns IP address bro. Whats problem ? – Rakesh Sojitra Jan 30 '16 at 09:23
  • 1
    http://php.net/manual/en/function.gethostbyname.php -> `Returns the IPv4 address or a string containing the unmodified hostname on failure.` . if you want to get server ip, try `$server_ip = gethostbyname(gethostname());` from http://stackoverflow.com/questions/5800927/how-to-identify-server-ip-address-in-php – Andrew Jan 30 '16 at 09:29
  • problem solved by mistakenly i forget to use trime() – Sarjerao Ghadage Jan 30 '16 at 09:38

1 Answers1

4

As mentioned in the documentation:

Returns the IPv4 address or a string containing the unmodified hostname on failure.

So you are on a failure situation.

Peyman Mohamadpour
  • 17,954
  • 24
  • 89
  • 100