Jump to content

Archived

This topic is now archived and is closed to further replies.

bcamp1973

can you capture server IP address?

Recommended Posts

I run a local dev environment and i want to put a <base href=""> tag in my dev sites so my colleagues can look at things as i'm working on them. So, say my ip is 123.45.67.01 and my project is in the "proj01" directory. I want to use PHP to build the following <base> tag...

[code]

<base href="http://123.45.67.01/proj01/" />

[/code]

obviously $_SERVER['HTTP_HOST'] doesn't work...is there a field in the server array for the IP address (and i don't mean 127.0.0.1) or any other way to capture that information?

Share this post


Link to post
Share on other sites
[!--quoteo(post=374471:date=May 16 2006, 07:06 PM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ May 16 2006, 07:06 PM) [snapback]374471[/snapback][/div][div class=\'quotemain\'][!--quotec--]
$_SERVER['SERVER_ADDR']
[/quote]

unfortunately that gives me "127.0.0.1", not the IP my colleagues need to access my macine :(

Share this post


Link to post
Share on other sites
really? hmm. well i tested it on my host and it seemed to work just fine? i'm not an expert so i couldn't tell you why it doesn't work. sorry...

Share this post


Link to post
Share on other sites
Either one should work!?

Are you accessing the script with [a href=\"http://localhost\" target=\"_blank\"]http://localhost[/a] or 127.0.0.1 (loopback) or [a href=\"http://yourIPaddresshere\" target=\"_blank\"]http://yourIPaddresshere[/a]?

All of them make a difference. Obviously your colleagues will have to use [a href=\"http://yourIPaddresshere\" target=\"_blank\"]http://yourIPaddresshere[/a] since they are outside of your network.

Try it, I bet it works [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]

Easy way to test which one works for you is to run phpinfo() with all three methods mentioned above. You will see the difference.

Share this post


Link to post
Share on other sites
[!--quoteo(post=374517:date=May 16 2006, 09:48 PM:name=exeterdad)--][div class=\'quotetop\']QUOTE(exeterdad @ May 16 2006, 09:48 PM) [snapback]374517[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Either one should work!?
[/quote]

ok, i'm an idiot. You're both right, it does work. The only failure here was my typing skills. I overlooked a typo. THanks to you both!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.