Skip to content

Instantly share code, notes, and snippets.

@underdown
Created October 9, 2012 20:23
Show Gist options
  • Select an option

  • Save underdown/3861198 to your computer and use it in GitHub Desktop.

Select an option

Save underdown/3861198 to your computer and use it in GitHub Desktop.
Get Client IP Address
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else if (isset($_SERVER['REMOTE_ADDR'])) {
$ip_address = $_SERVER['REMOTE_ADDR'];
} else if (isset($_SERVER['HTTP_CLIENT_IP'])) {
$ip_address = $_SERVER['HTTP_CLIENT_IP'];
} else {
$ip_address = '';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment