The simplest way to get the visitor’s/client’s IP address is using the
<?php
$location = file_get_contents('http://freegeoip.net/json/'.'166.62.6.39');
print_r($location);
$ip = '166.62.6.39';
$details = json_decode(file_get_contents("http://ipinfo.io/{$ip}/json"));
echo $details->city.$details->country;
exit;
?>
$_SERVER['REMOTE_ADDR'] or $_SERVER['REMOTE_HOST'] variables. |
$location = file_get_contents('http://freegeoip.net/json/'.'166.62.6.39');
print_r($location);
$ip = '166.62.6.39';
$details = json_decode(file_get_contents("http://ipinfo.io/{$ip}/json"));
echo $details->city.$details->country;
exit;
?>
get ip address in php simple and easy / get-the-client-ip-address-using-php
No comments:
Post a Comment