Getting the IP of a remote machine that requests a page via PHP is simple. On top of that there are services on the web where you can do it. whatismyip.com or ipecho.net are two of the more popular among them.
The purpose of this however is to provide myself with my own means of getting an external IP while I am out running around or at home without running in to any limitations. Plus why provide another site with hits and have adds crammed down my internet pipe if I can do this myself? I prefer a bit of self reliance…
On to some simple PHP code:
<?php $ip = $_SERVER['REMOTE_ADDR']; echo $ip; ?>
Simple snippet of code saved in to a file all by itself and served up by a PHP capable web server. The page is found on this site here! Curerntly publicly accessible and with no limits.
It is very spare in that it will simply output the IP address of the requester. It makes no attempt to deal with proxies or any other fancy network shenanigans. The goal is to have output that can be pulled via a script using say curl or wget.