Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gethostbyaddr($_SERVER['REMOTE_ADDR']) php

Tags:

php

Why does gethostbyaddr($_SERVER['REMOTE_ADDR']) return an IP address as opposed to a computer name as it should. It works as intended on 50 computers here in the office and returns the computer name. At the moment it returns an IP address on my own computer when it should return a computer name.

Is there a quick fix for this?

like image 967
David Egan Avatar asked Aug 03 '26 02:08

David Egan


1 Answers

From the documentation:

gethostbyaddr — Get the Internet host name corresponding to a given IP address

The important part is Internet, what PHP do is a DNS lookup. At your office your roouter may make a DNS resolve for local machines, but your home is not registered on any DNS.

For depending of your need your could use : How can I read the client's machine/computer name from the browser?

But this is not something easy to do.

like image 151
Larandar Avatar answered Aug 04 '26 17:08

Larandar