note 119535 added to function.gethostbynamel
| From: | ab at null dot ixo dot ca | Date: | Fri, 01 Jul 2016 14:44:15 +0000 |
| Subject: | note 119535 added to function.gethostbynamel | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-205857@lists.php.net to get a copy of this message | ||
If using gethostbyname against the name of the localhost is always giving you 127.0.0.1 but you want
the DNS address instead, just put a dot at the end of the name. E.g.,
$foo = gethostbynamel("myhost.example.com");
print_r($foo);
...is giving you this:
Array
(
[0] => 127.0.0.1
)
Then put a dot at the end of the name:
$foo = gethostbynamel("myhost.example.com.");
print_r($foo);
...and now you get something like:
Array
(
[0] => 172.217.1.99
)
----
Server IP: 216.235.13.26
Probable Submitter: 156.57.26.172
----
Manual Page -- http://php.net/manual/en/function.gethostbynamel.php
Edit -- https://master.php.net/note/edit/119535
Del: integrated -- https://master.php.net/note/delete/119535/integrated
Del: useless -- https://master.php.net/note/delete/119535/useless
Del: bad code -- https://master.php.net/note/delete/119535/bad+code
Del: spam -- https://master.php.net/note/delete/119535/spam
Del: non-english -- https://master.php.net/note/delete/119535/non-english
Del: in docs -- https://master.php.net/note/delete/119535/in+docs
Del: other reasons-- https://master.php.net/note/delete/119535
Reject -- https://master.php.net/note/reject/119535
Search -- https://master.php.net/manage/user-notes.php