| George Kinney 2004-07-26, 8:55 pm |
|
"steve" <UseLinkToEmail@dbForumz.com> wrote in message
news:wkiLc.56441$5Y.4868@cyclops.nntpserver.com...
>
> I don't have DNS on my pc, so I tried
> gethostbynamel('localhost')
> but it returns 127.0.0.1[/quote:a576311143]
>
> It works! must do it this way:
> $hosts=gethostbynamel(''); (see
>
http://ca2.php.net/manual/en/functi...hostbynamel.php)[/quote:a576311143]
>
> And a quick note, the $hosts variable above is an array. Take
> $hosts[0] as the IP number!
Just to clarify: getbyhostname('localhost') *should* return 127.0.0.1, since
it almost always
defined as such in your hosts file. You should actually either use '', like
you did, or your known
machine name 'someserver.somedomain.com' if you want its actual IP.
And you don't need to have DNS on your PC, if you can look up *any* hostname
(not already
defined in your hosts file) then you are accessing a DNS server somewhere.
(look up anything
via nslookup at a command line, and it will tell you what server you are
currently using as part of
its response.)
|