note 25091 added to function.gethostbyaddr

From: Date: Tue, 10 Sep 2002 12:17:17 +0000
Subject: note 25091 added to function.gethostbyaddr
Groups: php.notes 
Request: Send a blank email to php-notes+get-36455@lists.php.net to get a copy of this message
gethostbyaddr_with_cache() As someone truely said upper in the forum, some unresolved addresses may slow down your script to the point it times out. Althought I had thought gethostbyaddr() would use some kind of cache, it doesn't seem to when the IP is unresolved (at least on my win machine). So, I've coded a little gethostbyaddr_with_cache() function that will greatly speed your page if you have many gethostbyaddr() to perform on the same page. function gethostbyaddr_with_cache($a) { global $dns_cache; if ($dns_cache[$a]) { return $dns_cache[$a]; } else { $temp = gethostbyaddr($a); $dns_cache[$a] = $temp; return $temp; } } -- http://www.php.net/manual/en/function.gethostbyaddr.php http://master.php.net/manage/user-notes.php?action=edit+25091 http://master.php.net/manage/user-notes.php?action=delete+25091 http://master.php.net/manage/user-notes.php?action=reject+25091

« previous php.notes (#36455) next »