Page 1 of 1

URL to IP conversion

Posted: Mon Feb 04, 2008 4:31 pm
by Zanne
Is there a way I can convert a url to an IP?

Ex:
I enter:
http://www.google.com

Script returns:
64.233.161.104

Thanks,

Zanne

Re: URL to IP conversion

Posted: Mon Feb 04, 2008 4:33 pm
by arjan.top
function gethostbyname()

http://si2.php.net/gethostbyname

Re: URL to IP conversion

Posted: Mon Feb 04, 2008 4:38 pm
by Zanne
Thank you once again. The code works fine =)

Re: URL to IP conversion

Posted: Mon Feb 04, 2008 9:54 pm
by mhonnphp
how about the visitors IP?

Re: URL to IP conversion

Posted: Mon Feb 04, 2008 10:03 pm
by Christopher
$_SERVER["REMOTE_ADDR"]

Re: URL to IP conversion

Posted: Wed Feb 06, 2008 9:40 pm
by mhonnphp
arborint wrote:$_SERVER["REMOTE_ADDR"]
arborint thanks for the reply.
but why it is different with the actual Visitors IP?
I echo $_SERVER["REMOTE_ADDR"] the result is xxx.x.x.x
example 123.0.0.0 but the actual Visitor IP is 192.168.xxx.xxx
is this accurate? and Please explain thanks.

Re: URL to IP conversion

Posted: Wed Feb 06, 2008 10:18 pm
by Zanne
mhonnphp wrote:
arborint wrote:$_SERVER["REMOTE_ADDR"]
arborint thanks for the reply.
but why it is different with the actual Visitors IP?
I echo $_SERVER["REMOTE_ADDR"] the result is xxx.x.x.x
example 123.0.0.0 but the actual Visitor IP is 192.168.xxx.xxx
is this accurate? and Please explain thanks.
The 192.168.xxx.xxx is the network IP address assigned to the computer. However, what the server sees is the DNS address. to obtain the actual Visitor's IP address, try going to this link: http://www.whatsmyrealip.com

That link will tell you your actuall IP address the server will see and recognize.

Re: URL to IP conversion

Posted: Thu Feb 07, 2008 7:43 pm
by mhonnphp
Zanne wrote:
mhonnphp wrote:
arborint wrote:$_SERVER["REMOTE_ADDR"]
arborint thanks for the reply.
but why it is different with the actual Visitors IP?
I echo $_SERVER["REMOTE_ADDR"] the result is xxx.x.x.x
example 123.0.0.0 but the actual Visitor IP is 192.168.xxx.xxx
is this accurate? and Please explain thanks.
The 192.168.xxx.xxx is the network IP address assigned to the computer. However, what the server sees is the DNS address. to obtain the actual Visitor's IP address, try going to this link: http://www.whatsmyrealip.com

That link will tell you your actuall IP address the server will see and recognize.
Ah ok, then how can I get the real IP?

Re: URL to IP conversion

Posted: Thu Feb 07, 2008 11:03 pm
by Kieran Huggins
You can't - if you're on a network with a router then your IP is masked. It doesn't really matter though, because your "real IP" only means something on your local network anyway.