凌的博客

您现在的位置是: 首页 > 学无止境 > PHP > 

PHP

最新的ip库分享

2015-11-03 PHP 602
淘宝1.7版本的ip地址库,这个是比较新的从网上找到的。附上使用方法 //IP转换成地址 function getIp($ip){ $taobaoIP = \'http://ip.taobao.com/service/getIpInfo.php?ip=\'.$ip; $IPinfo = json_dec

淘宝1.7版本的ip地址库,这个是比较新的从网上找到的。附上使用方法

//IP转换成地址
function getIp($ip){
  $taobaoIP = 'http://ip.taobao.com/service/getIpInfo.php?ip='.$ip;
  $IPinfo = json_decode(file_get_contents($taobaoIP));
  $province = $IPinfo->data->region;
  $city = $IPinfo->data->city;
  $data = $province.$city;
  return $data;
}
xxxxxxxxxx


	header('Content-Type: text/html; charset=utf-8;');
	define(ql_DIR,getcwd().'/');
	require 'IP.class.php';
	function getIp($ip){
		$ads = IP::find($ip);
		if($ip=='127.0.0.1')
		$ads = "本机地址";
		else
		$ads = $ads[1].'省'.$ads[2].'市'.$ads[3];
		return $ads;
	}
	
	echo getIp('112.236.25.254');





文章评论

0条评论