Page 1 of 1

Translating url

Posted: Fri Aug 28, 2009 1:34 pm
by yoger
Hello everybody!
I need to know something about php.
So, I'm gathering my server URL by command $_SERVER['HTTP_HOST'] but it returns somethink like myserver.com just string, but I need to translate it to numarical IP address like 127.0.0.1.
Is there in PHP any function that can help me with that?

Re: Translating url

Posted: Fri Aug 28, 2009 1:43 pm
by sousousou
$_server[’SERVER_ADDR’] ?

Re: Translating url

Posted: Fri Aug 28, 2009 1:44 pm
by Eran

Re: Translating url

Posted: Fri Aug 28, 2009 1:49 pm
by yoger
That would be too easy, SERVER_ADDR returns my routers IP, which is 192.168.1.10, when I need my IP (which is atm 83.21.154.63). Any other ideas?

Re: Translating url

Posted: Fri Aug 28, 2009 2:06 pm
by Eran
you need to know your external IP? your computer can't tell you this. You need to speak with router somehow, which would probably involve invoking a shell command.

Re: Translating url

Posted: Fri Aug 28, 2009 2:14 pm
by sousousou
I'm not very advanced, but maybe try something with gethostbyname() ?

Re: Translating url

Posted: Fri Aug 28, 2009 3:53 pm
by yoger
No idea how but it works :D
Thanks for this pal!

Re: Translating url

Posted: Fri Aug 28, 2009 4:04 pm
by sousousou
yoger wrote:No idea how but it works :D
Thanks for this pal!
:dubious: First time I've ever solved someone else's PHP problem :dubious:

Re: Translating url

Posted: Fri Aug 28, 2009 4:27 pm
by John Cartwright
sousousou wrote:
yoger wrote:No idea how but it works :D
Thanks for this pal!
:dubious: First time I've ever solved someone else's PHP problem :dubious:
:drunk: