随笔 - 579  文章 - 2 评论 - 35 阅读 - 56万
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

<?php
  /* 调用腾讯的API接口
0 为 IP地址
1 为 null
2 为 省份
3 为 城市*/
function get_ip_place(){  
$ip=file_get_contents("http://fw.qq.com/ipaddress");  
$ip=str_replace('"',' ',$ip);   
$ip2=explode("(",$ip);   
$a=substr($ip2[1],0,-2);   
$b=explode(",",$a);   
return $b;   
}   
$ip=get_ip_place();   
print_r($ip);   
print_r($ip[0]); // 这个就是你当前外网IP地址
print_r($ip[2]); // 这个就是你所在的省份
print_r($ip[3]); //这个就是你所在的城市了
?>
posted on   Dufe王彬  阅读(1874)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示