PHP通过IP获取地理位置代码

用php获取ip地址后如何获取地理位置,看下下面代码:

function get_ip_place()

{     $ip=file_get_contents("http://fw.qq.com/ipaddress");     $ip=str_replace('"',' ',$ip);     $ip2=explode("(",$ip);     $a=substr($ip2[1],0,-2);     $b=explode(",",$a);     return $b; }   还有一种办法:   来看看  function get_ip_arr() {     $ip=file_get_contents("http://fw.qq.com/ipaddress");     preg_match_all("/"(.*)"/",$ip,$arr);     return $arr; } 返回来的是个数组,里面可以任意去取地区或者是ip

时间: 2024-08-02 21:20:02

PHP通过IP获取地理位置代码的相关文章

php利用新浪接口查询ip获取地理位置

 这篇文章主要介绍了php利用新浪接口查询ip获取地理位置示例,大家参考使用吧  代码如下: <?php  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 ,'utf

Node.js和PHP根据ip获取地理位置的方法

这篇文章主要介绍了Node.js和PHP根据ip获取地理位置的方法,通过新浪接口根据IP地址获取所在城市,需要的朋友可以参考下 一.Node.js实现代码  代码如下: var http = require('http'); var util = require('util');   /**  * 根据 ip 获取获取地址信息  */ var getIpInfo = function(ip, cb) {     var sina_server = 'http://int.dpool.sina.c

PHP安装GeoIP扩展根据IP获取地理位置及计算距离的方法_php实例

根据IP获取访客所在国家/城市/经纬度安装GeoIP扩展: sudo apt-get install libgeoip-dev pecl install geoip-1.1.0 注意:Beta版要指定版本号.如果是apt安装的PHP,直接安装php5-geoip这个包即可. php.ini中加入: extension=geoip.so geoip.custom_directory="/usr/share/GeoIP" 免费下载GeoLiteCity数据库(解压后18MB): http:

PHP安装GeoIP扩展根据IP获取地理位置及计算距离的方法

根据IP获取访客所在国家/城市/经纬度 安装GeoIP扩展: sudo apt-get install libgeoip-dev pecl install geoip-1.1.0 注意:Beta版要指定版本号.如果是apt安装的PHP,直接安装php5-geoip这个包即可. php.ini中加入: extension=geoip.so geoip.custom_directory="/usr/share/GeoIP" 免费下载GeoLiteCity数据库(解压后18MB): http

php下通过IP获取地理位置的代码(小偷程序)

复制代码 代码如下: function get_ip_place() { $ip=file_get_contents("http://fw.qq.com/ipaddress"); $ip=str_replace('"',' ',$ip); $ip2=explode("(",$ip); $a=substr($ip2[1],0,-2); $b=explode(",",$a); return $b; } 上面来自开源中国写的真XXX,新闻我都

php下通过IP获取地理位置的代码(小偷程序)_php技巧

复制代码 代码如下: function get_ip_place() { $ip=file_get_contents("http://fw.qq.com/ipaddress"); $ip=str_replace('"',' ',$ip); $ip2=explode("(",$ip); $a=substr($ip2[1],0,-2); $b=explode(",",$a); return $b; } 上面来自开源中国写的真XXX,新闻我都

php利用新浪接口查询ip获取地理位置示例_php实例

复制代码 代码如下: <?php 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_TIMEOU

通过IP获取地理位置

 function get_ip_place() {     $ip=file_get_contents("http://fw.qq.com/ipaddress");     $ip=str_replace('"',' ',$ip);     $ip2=explode("(",$ip);     $a=substr($ip2[1],0,-2);     $b=explode(",",$a);     return $b; }   上面来

c#&amp;amp;amp;winform符合获取地理位置信息

问题描述 如图,想通过winform获取pc机的地理位置信息如何实现?谢谢 解决方案 解决方案二:电脑没装GPS,所以一般联网才能通过IP地址获取把,可以往这方面考虑解决方案三:考虑通过IP获取地理位置的API