Copy CodeThe code is as follows:
function Getiploc_sina ($queryIP) {
$url = ' http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip= '. $queryIP;
$ch = Curl_init ($url);
curl_setopt ($ch, curlopt_encoding, ' UTF8 ');
curl_setopt ($ch, Curlopt_timeout, 5);
curl_setopt ($ch, Curlopt_returntransfer, true); Get Data back
$location = curl_exec ($ch);
$location = Json_decode ($location);
Curl_close ($ch);
$loc = "";
if ($location ===false) return "";
if (Empty ($location->desc)) {
$loc = $location->province. $location->city. $location->district. $location->isp;
}else{$loc = $location->desc;
}
return $loc;
}
Echo Getiploc_sina ("183.37.209.57");
?>
http://www.bkjia.com/PHPjc/718616.html www.bkjia.com true http://www.bkjia.com/PHPjc/718616.html techarticle Copy the code as follows: Php function Getiploc_sina ($queryIP) {$url = ' http://int.dpool.sina.com.cn/iplookup/iplookup.php? Format=json $ch = Curl_init ($url); curl_setopt ($ch, CURL ...