Sarjerao Ghadage
Sarjerao Ghadage

Reputation: 1544

PHP gethostbyname returns hostname instead of IP address

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

Upvotes: 2

Views: 2838

Answers (1)

Peyman Mohamadpour
Peyman Mohamadpour

Reputation: 17944

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.

Upvotes: 4

Related Questions