Jump to content

can you capture server IP address?


bcamp1973

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?
Link to comment
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 :(
Link to comment
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.
Link to comment
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!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.