As all others said before you can use $_SERVER['REMOTE_ADDR'];
to get the client IP address.
Also, if you need more information about a user, you can use this:
" . $clientDetails->country . "";
?>
Client's more specific information goes in $clientDetails.
You can fetch JSON items stored in $clientDetails variable this way: $clientDetails->PostalCode/hostname/region/loc...
I'm using ipinfo.io to get extra information.