Skip to content

Instantly share code, notes, and snippets.

@jefferyrdavis
Created July 13, 2013 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jefferyrdavis/5992224 to your computer and use it in GitHub Desktop.
Save jefferyrdavis/5992224 to your computer and use it in GitHub Desktop.
Snippit: PHP: Get Client IP Address
<?php
// Used to determine the IP address of the client.
function GetIpAddr()
{
if (!empty($_SERVER['HTTP_CLIENT_IP']))
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}
?>
@TestoEXE
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment