Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
codejobs - Get IP - PHP
<?php
function getIP() {
if(isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
if(isset($_SERVER["HTTP_CLIENT_IP"])) {
return $_SERVER["HTTP_CLIENT_IP"];
} else {
return $_SERVER["REMOTE_ADDR"];
}
return $_SERVER["HTTP_X_FORWARDED_FOR"];
} else {
if(isset($_SERVER["HTTP_CLIENT_IP"])) {
return $_SERVER["HTTP_CLIENT_IP"];
} else {
return $_SERVER["REMOTE_ADDR"];
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.