PHP uses Tencent IP sharing plan to obtain geographical location example sharing_PHP tutorial

WBOY
Release: 2016-07-13 10:40:27
Original
837 people have browsed it

Copy code The code is as follows:

function getIPLoc_QQ($queryIP){ 
$ url = 'http://ip.qq.com/cgi-bin/searchip?searchip1='.$queryIP;
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_ENCODING ,'gb2312 ');
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Get data and return
$result = curl_exec($ch);
$ result = mb_convert_encoding($result, "utf-8", "gb2312"); // Encoding conversion, otherwise garbled characters
curl_close($ch);
preg_match("@(.*)< ;/span>

@iU",$result,$ipArray);
$loc = $ipArray[1];
return $loc;
}
//Use
echo getIPLoc_QQ("183.37.209.57"); //You can get the address location of the IP address.
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/718618.htmlTechArticleCopy the code as follows: ?php function getIPLoc_QQ($queryIP){ $url = 'http://ip. qq.com/cgi-bin/searchip?searchip1='.$queryIP; $ch = curl_init($url); curl_setopt($ch,CURLOPT_ENCOD...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!