note 40770 added to function.gethostbyaddr
| From: | webmaster at script-tease dot net | Date: | Sun, 14 Mar 2004 09:37:03 +0000 |
| Subject: | note 40770 added to function.gethostbyaddr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-66808@lists.php.net to get a copy of this message | ||
gethostbyaddr() tends to lag on various systems for whatever reason. Here are two functions that
should prove their worth speedwise.
<?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));
}
?>
Pretty basic, but it should get the job done.
----
Manual Page -- http://www.php.net/manual/en/function.gethostbyaddr.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40770
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40770&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40770&report=yes
Search -- http://master.php.net/manage/user-notes.php