Muffinresearch Labs by Stuart Colville

PHP tip of the week: Getting IP addresses | Comments (2)

Posted in Code on 2nd December 2004, 1:07 pm by Stuart

Extracting the gateway IP address is straightforward:

$ip = $_SERVER['REMOTE_ADDR'];

To obtain the hostname of the gateway IP address just do the following:

$hostname = GetHostByName($_SERVER['REMOTE_ADDR']);

To get the local IP address of your user can sometimes be useful too. Here’s how:

$localip = $HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'];

Post Tools

Comments: Add yours

1. On March 28th, 2005 at 4:57 pm Q... said:

I wanted to cite some of your posts in my forum. Couldn’t find your perma-links

2. On March 29th, 2005 at 8:27 am Stuart Colville said:

Hi, I’m as we speak working on the first draft of Joornal which will be a re-written blogging script to replace this one. There’s no question that permalinks will become a feature of this. Watch this space.







XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>



DjangoCon 2008 Announced|(0)

Rob’s just announced on Twitter that the DjangoCon 2008 will be held at the GooglePlex on 6-7th September. More details will be announced on http://djangoproject.com in due course. Also the DjangoCon Site will be up this coming Friday. via EvilRob’s Twitter Page

The Troggs Tapes|(1)

It’s been a while since I heard this legendary recording of the Troggs arguing in the studio control room. The recording is said to have inspired some of the scenes in Spinal Tap. Download the .mp3 at the web archive. (Warning: This recording contains lots of expletives!!)

Dubba, dubba, dubba cha!!

Photos on Flickr

© Copyright 2004-08 Stuart Colville, all rights reserved. May contain traces of Muffin. Powered by WordPress. Hosting by 1&1 This page was baked in 0.913s.