Can you be more specific to as why you want the IP address. The reason I ask is that not too long ago that a site currently under development was hit with a log spammer. My first plan was to ban the IP address. After some investigation it became apparent that in some situations an IP address works well (and fortunately it worked well with the log spammer), but it appears that it shouldn't be relied upon.
For one thing many users are assigned dynamic IP addresses, which means that the IP is going to mean little. Other vistors don't register a real IP address.
I'm no expert in this and can only share with you what I've found through talking with others. It might help if you explained the purpose of wanting the IP address.
BTW you should be able to find a simple PHP script somewhere--it's really a simple line of code.