Skip to content

Instantly share code, notes, and snippets.

@georgebent
Last active March 3, 2018 08:38
Show Gist options
  • Save georgebent/6070ed7cd8075ad63df07c7afb9c947e to your computer and use it in GitHub Desktop.
Save georgebent/6070ed7cd8075ad63df07c7afb9c947e to your computer and use it in GitHub Desktop.
PHP examples
function getIp()
{
//check ip from share internet
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
return $_SERVER['HTTP_CLIENT_IP'];
}
//to check ip is pass from proxy
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
return $_SERVER['HTTP_X_FORWARDED_FOR'];
}
return $_SERVER['REMOTE_ADDR'];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment