denoteone Posted February 3, 2009 Share Posted February 3, 2009 I am using gethostbyaddr to resolve a site visitors IP. Would this be the same as a reverse look up on an IP? Would this be the same as using Network Solutions Whois search? I am getting some weird entries in my database. lol Any body have any insight on this? Link to comment https://forums.phpfreaks.com/topic/143687-reverse-lookup-with-ip/ Share on other sites More sharing options...
denoteone Posted February 4, 2009 Author Share Posted February 4, 2009 ok let me ask this a different way. why if I look up an IP address with gethostbyaddr(); sometimes it just returns the ip again. but if I look the same IP up on www.who.is I get more info. where does the gethostbyaddr(); function get its info. is there another php function that would work better for this? Link to comment https://forums.phpfreaks.com/topic/143687-reverse-lookup-with-ip/#findComment-754555 Share on other sites More sharing options...
sdi126 Posted February 4, 2009 Share Posted February 4, 2009 The IP address is returned on failure of the function call. I found these on php.net...might work for you: <?php // For Linux... function gethost ($ip) { $host = `host $ip`; return (($host ? end ( explode (' ', $host)) : $ip)); } // For Win32... function nslookup ($ip) { $host = split('Name:',`nslookup $ip`); return ( trim (isset($host[1]) ? str_replace ("\n".'Address: '.$ip, '', $host[1]) : $ip)); } ?> Link to comment https://forums.phpfreaks.com/topic/143687-reverse-lookup-with-ip/#findComment-754676 Share on other sites More sharing options...
The Little Guy Posted February 4, 2009 Share Posted February 4, 2009 Is something like this what your looking for? echo $_SERVER['REMOTE_ADDR']; Link to comment https://forums.phpfreaks.com/topic/143687-reverse-lookup-with-ip/#findComment-754698 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.