function标签:return,ip,res1,获取,地址,data From: https://blog.51cto.com/u_14934686/5746107
getcposition(
$ip
){
try
{
$res1
=
file_get_contents
(
"http://ip.taobao.com/service/getIpInfo.php?ip=$ip"
);
$res1
= json_decode(
$res1
,true);
if
(
$res1
[
"code"
]==0){
return
$res1
[
'data'
][
"country"
].
$res1
[
'data'
][
"region"
].
$res1
[
'data'
][
"city"
].
"_"
.
$res1
[
'data'
][
"isp"
];
}
else
{
return
"未能获取"
;
}
}
catch
(Exception
$e
){
return
"未能获取"
;
}
}