note 119721 added to function.gethostbyname
| From: | gabriel at nexcore dot com dot br | Date: | Wed, 10 Aug 2016 21:43:49 +0000 |
| Subject: | note 119721 added to function.gethostbyname | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-206255@lists.php.net to get a copy of this message | ||
For the "dig" solution, here is a better one:
<?php
$IP =
/usr/bin/dig $host. A +short | /usr/bin/tail -n1
?>
Using tail because dig, even in the +short form, may return CNAME entries first, and also may return
many, many entries (see "dig google.com").
Usig the dot at the end of the host to not perform domain searches.
This works also when $host = IP address already
Will return empty string in case o resolve failure (invalid hostname)
----
Server IP: 72.52.91.14
Probable Submitter: 187.95.127.83
----
Manual Page -- http://php.net/manual/en/function.gethostbyname.php
Edit -- https://master.php.net/note/edit/119721
Del: integrated -- https://master.php.net/note/delete/119721/integrated
Del: useless -- https://master.php.net/note/delete/119721/useless
Del: bad code -- https://master.php.net/note/delete/119721/bad+code
Del: spam -- https://master.php.net/note/delete/119721/spam
Del: non-english -- https://master.php.net/note/delete/119721/non-english
Del: in docs -- https://master.php.net/note/delete/119721/in+docs
Del: other reasons-- https://master.php.net/note/delete/119721
Reject -- https://master.php.net/note/reject/119721
Search -- https://master.php.net/manage/user-notes.php