1 $ip = $_SERVER["REMOTE_ADDR"]; 2 $url = "http://ip.taobao.com/service/getIpInfo.php?ip=".$ip; 3 $json = file_get_contents($url); 4 $arr = json_decode($json); 5 echo '<pre>'; 6 var_dump($arr); 7 8 9 echo $arr->data->region; 10 echo $arr->data->city; 11 echo $arr->data->ip;