$queryip = @file_get_contents('http://ip.taobao.com/service/getIpInfo.php?ip='.$ipaddd);
$queryip = json_decode($queryip,true);
$queryip = $queryip['data'];
$queryip = $queryip['region_id'];
1
shyling 2015 年 12 月 25 日 via iPad
没问题
|
2
qiayue PRO 最后两句有问题,第三句会被第四句覆盖
|
3
sun2920989 2015 年 12 月 25 日
只能说不会有语法错误
|
4
wwek 2015 年 12 月 25 日
要加 timeout 否则网络有问题会卡住的
|
5
quericy 2015 年 12 月 25 日
为什么用 file_get_contents 而不用 curl...
|
6
lijinma 2015 年 12 月 25 日
第三四句很可能 PHP error:
Undefined index: data Undefined index: region_id 建议从数组中取值的时候判断存在 key $queryip = isset($queryip['data']) ? $queryip['data'] : ''; 如果是 PHP7 ,可以这样,更简单: $queryip = $queryip['data'] ?? ''; |