note 117834 added to function.gethostbyname
| From: | php at nemon dot be | Date: | Mon, 17 Aug 2015 16:14:32 +0000 |
| Subject: | note 117834 added to function.gethostbyname | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203368@lists.php.net to get a copy of this message | ||
Always add the root . at the end or your server can add it's own suffix.
example: abc.com could become abc.com.yourcompany.com if you don't use abc.com.
I also find this function a litle bit limited because it doesn't tell you if the resolve
failed.
TO adress all those issues I use :
function host2ip($host)
{
$host=trim($host.'.'); // clean and add root .
$ip= gethostbyname($host);
if($ip==$host) $ip='';// empty IP if there is no ip
return $ip;
}
----
Server IP: 72.52.91.14
Probable Submitter: 78.22.3.138
----
Manual Page -- http://php.net/manual/en/function.gethostbyname.php
Edit -- https://master.php.net/note/edit/117834
Del: integrated -- https://master.php.net/note/delete/117834/integrated
Del: useless -- https://master.php.net/note/delete/117834/useless
Del: bad code -- https://master.php.net/note/delete/117834/bad+code
Del: spam -- https://master.php.net/note/delete/117834/spam
Del: non-english -- https://master.php.net/note/delete/117834/non-english
Del: in docs -- https://master.php.net/note/delete/117834/in+docs
Del: other reasons-- https://master.php.net/note/delete/117834
Reject -- https://master.php.net/note/reject/117834
Search -- https://master.php.net/manage/user-notes.php