I just ran into a situation for a Drupal/PHP client where I wanted to log some access information. There was some unusual access activity on the website, and I want to log IP addresses and URLs for a few days.
As part of that, I wanted to get the web client's IP address, and in PHP you get the client IP address like this:
$ip = $_SERVER['REMOTE_ADDR'];
That returns something like this:
If you just need to get a web client's IP address from a PHP script, that's all you need.