function visitorip() {
if (getenv('HTTP_CLIENT_IP')) $ip = getenv('HTTP_CLIENT_IP');
elseif (getenv('HTTP_X_FORWARDED_FOR')) $ip = getenv('HTTP_X_FORWARDED_FOR');
elseif (getenv('HTTP_X_FORWARDED')) $ip = getenv('HTTP_X_FORWARDED');
elseif (getenv('HTTP_FORWARDED_FOR')) $ip = getenv('HTTP_FORWARDED_FOR');
elseif (getenv('HTTP_FORWARDED')) $ip = getenv('HTTP_FORWARDED');
else $ip = $_SERVER['REMOTE_ADDR'];
return $ip;
}
echo "Your IP address is ".visitorip();
?>
In result web site visitor's ip address will appear. In example above i made a function named visitorip() will check all conditions for getting ip and will return ip address. echo command of PHP will receive ip address will display on page.
RSS Feeds
File Under :






0 comments:
Post a Comment