note 70408 added to function.gethostbyname
| From: | chrisatchollisdotnet at osu1 dot php dot net | Date: | Sun, 15 Oct 2006 17:57:27 +0000 |
| Subject: | note 70408 added to function.gethostbyname | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-118548@lists.php.net to get a copy of this message | ||
mmucklo raises a valid point, however the function to use would be getmxrr() in the simplest case,
or alternatively checkdnsrr() if you so wish; getdnsrr() does not exist.
On another note, it can be a pain (when iterating with while loops for example) that on failure
gethostbyname() returns the hostname, rather than FALSE. You could wrap it in a simple user
function, to "correct" this:
<?php
function fixed_gethostbyname ($host) {
// Try the lookup as normal...
$ip = gethostbyname($host);
// ...but if it fails, FALSE is returned instead of the unresolved host
if ($ip != $host) { return $ip; } else return false;
}
?>
----
Server IP: 85.116.0.130
Probable Submitter: 172.209.61.203
----
Manual Page -- http://www.php.net/manual/en/function.gethostbyname.php
Edit -- https://master.php.net/note/edit/70408
Del: integrated -- https://master.php.net/note/delete/70408/integrated
Del: useless -- https://master.php.net/note/delete/70408/useless
Del: bad code -- https://master.php.net/note/delete/70408/bad+code
Del: spam -- https://master.php.net/note/delete/70408/spam
Del: non-english -- https://master.php.net/note/delete/70408/non-english
Del: in docs -- https://master.php.net/note/delete/70408/in+docs
Del: other reasons-- https://master.php.net/note/delete/70408
Reject -- https://master.php.net/note/reject/70408
Search -- https://master.php.net/manage/user-notes.php