-
-
Save rkmaier/2037822 to your computer and use it in GitHub Desktop.
PHP::Get Client IP adress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getIP() { | |
$ip; | |
if (getenv("HTTP_CLIENT_IP")) | |
$ip = getenv("HTTP_CLIENT_IP"); | |
else if(getenv("HTTP_X_FORWARDED_FOR")) | |
$ip = getenv("HTTP_X_FORWARDED_FOR"); | |
else if(getenv("REMOTE_ADDR")) | |
$ip = getenv("REMOTE_ADDR"); | |
else | |
$ip = "UNKNOWN"; | |
return $ip; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice job! Exactly what I needed. Works in Rackspace Cloud environment.