标签:
本篇文章由:http://xinpure.com/php-based-on-information-such-as-the-ip-address-in-your-city/
在 PHP 中得到当前访问者的IP地址,还是比较简单的:
$ip = $_SERVER[‘REMOTE_ADDR‘]
淘宝提供了一个IP数据接口:
http://ip.taobao.com/service/getIpInfo.php?ip=ip地址
$response = file_get_contents(‘http://ip.taobao.com/service/getIpInfo.php?ip=‘.$ip);
$result = json_decode($response);
print_r($result);
输出结果为:
stdClass Object
(
[code] => 0
[data] => stdClass Object
(
[country] => 中国
[country_id] => CN
[area] => 华南
[area_id] => 800000
[region] => 广东省
[region_id] => 440000
[city] => 深圳市
[city_id] => 440300
[county] =>
[county_id] => -1
[isp] => 电信
[isp_id] => 100017
[ip] => 183.16.191.102
)
)
参考链接: http://bbs.csdn.net/topics/390668296
标签:
原文地址:http://www.cnblogs.com/xinpureZhu/p/4240310.html