$_SERVER['REMOTE_ADDR'] - This works fine if the network your clients are on is trusted network, such as an internal company network.
However, if the IP address is a proxy server, you can use $_SERVER['HTTP_X_FORWARDED_FOR'] .
You may also include $_SERVER['HTTP_CLIENT_IP'] and use all three in your response variable.
$ipAddress = $_SERVER['HTTP_CLIENT_IP'] ? : ($_SERVER['HTTP_X_FORWARDED_FOR'] ? : $_SERVER['REMOTE_ADDR']);