note 99826 added to function.gethostbyaddr
| From: | Norf at osu1 dot php dot net | Date: | Thu, 09 Sep 2010 05:08:09 +0000 |
| Subject: | note 99826 added to function.gethostbyaddr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-172396@lists.php.net to get a copy of this message | ||
The dns_get_record function seems to avoid timeout problems caused by gethostbyaddr() when looking
up no existent records.
Example below.
<?php
function get_host($ip){
$ptr=
implode(".",array_reverse(explode(".",$ip))).".in-addr.arpa";
$host = dns_get_record($ptr,DNS_PTR);
if ($host == null) return $ip;
else return $host[0]['target'];
}
print get_host('192.168.1.5');
?>
----
Server IP: 69.147.83.197
Probable Submitter: 124.169.46.31
----
Manual Page -- http://www.php.net/manual/en/function.gethostbyaddr.php
Edit -- https://master.php.net/note/edit/99826
Del: integrated -- https://master.php.net/note/delete/99826/integrated
Del: useless -- https://master.php.net/note/delete/99826/useless
Del: bad code -- https://master.php.net/note/delete/99826/bad+code
Del: spam -- https://master.php.net/note/delete/99826/spam
Del: non-english -- https://master.php.net/note/delete/99826/non-english
Del: in docs -- https://master.php.net/note/delete/99826/in+docs
Del: other reasons-- https://master.php.net/note/delete/99826
Reject -- https://master.php.net/note/reject/99826
Search -- https://master.php.net/manage/user-notes.php