开发者

Resolve IP to Hostname using PHP

How can 开发者_如何转开发I resolve an IP address to a hostname using PHP?


You can use the gethostbyaddr() function.

$hostname = gethostbyaddr($ipAddress);


Use gethostbyaddr()

$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);

echo $hostname;

You might find that this function can hang for some time when an address is not found - if this becomes a performance issue for you, check this manual comment which details a hand-coded method which supports a timeout.


gethostbyaddr()


You should give gethostbyaddr() a shot.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜