最近2018中文字幕在日韩欧美国产成人片_国产日韩精品一区二区在线_在线观看成年美女黄网色视频_国产精品一区三区五区_国产精彩刺激乱对白_看黄色黄大色黄片免费_人人超碰自拍cao_国产高清av在线_亚洲精品电影av_日韩美女尤物视频网站

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
GeoIP庫怎么在php項(xiàng)目中運(yùn)用-創(chuàng)新互聯(lián)

GeoIP庫怎么在php項(xiàng)目中運(yùn)用?針對這個(gè)問題,這篇文章詳細(xì)介紹了相對應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問題的小伙伴找到更簡單易行的方法。

站在用戶的角度思考問題,與客戶深入溝通,找到枝江網(wǎng)站設(shè)計(jì)與枝江網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:網(wǎng)站設(shè)計(jì)制作、網(wǎng)站制作、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名注冊、雅安服務(wù)器托管、企業(yè)郵箱。業(yè)務(wù)覆蓋枝江地區(qū)。

一、GEOIP數(shù)據(jù)庫

細(xì)分到國家:GeoLite Country
細(xì)分到城市:GeoLite City

二、php官方geoip.dll庫

修改php.ini,啟用geoip庫:


復(fù)制代碼 代碼如下:

extension=php_geoip.dll


追加geoip段,指定數(shù)據(jù)庫位置:


復(fù)制代碼 代碼如下:

[geoip]
geoip.custom_directory = "D:\php5.3\geo\"

測試代碼

注意geoip.dll中使用的 GeoIPCity.dat 即 GeoLiteCity.dat,用的時(shí)候注意看提示


復(fù)制代碼 代碼如下:


echo geoip_country_name_by_name( "8.8.8.8" ) . "\n";
print_r( geoip_record_by_name( "8.8.8.8" ) );
echo geoip_country_name_by_name( "61.139.2.69" ). "\n";
print_r( geoip_record_by_name(  "61.139.2.69" ) );

三、MaxMind官方php文件函數(shù)庫

文檔和示例:http://dev.maxmind.com/geoip/downloadable
修改maxmind示例中 sample.php 和 sample_city.php 中 GeoIP.dat/GeoLiteCity.dat 路徑為你自己的路徑
同一目錄用 “./GeoIP.dat” 或 “./GeoLiteCity.dat” 即可。
詳細(xì)到國家


復(fù)制代碼 代碼如下:


include("geoip.inc");
$gi = geoip_open( "./GeoIP.dat", GEOIP_STANDARD );
echo geoip_country_code_by_addr($gi, "8.8.8.8") . "\t" . geoip_country_name_by_addr($gi, "8.8.8.8") . "\n";
echo geoip_country_code_by_addr($gi, "61.139.2.69") . "\t" . geoip_country_name_by_addr($gi, "61.139.2.69") . "\n";
geoip_close($gi);


詳細(xì)到國家城市

復(fù)制代碼 代碼如下:


include("geoipcity.inc");
include("geoipregionvars.php");
$gi = geoip_open("./GeoLiteCity.dat",GEOIP_STANDARD);
 
$record = geoip_record_by_addr($gi,"8.8.8.8");
print $record->country_code . " " . $record->country_code3 . " " . $record->country_name . "\n";
print $record->region . " " . $GEOIP_REGION_NAME[$record->country_code][$record->region] . "\n";
print $record->city . "\n";
print $record->postal_code . "\n";
print $record->latitude . "\n";
print $record->longitude . "\n";
print $record->metro_code . "\n";
print $record->area_code . "\n";
print $record->continent_code . "\n";
 
print "\n-----\n";
$record = geoip_record_by_addr($gi,"61.139.2.69");
print $record->country_code . " " . $record->country_code3 . " " . $record->country_name . "\n";
print $record->region . " " . $GEOIP_REGION_NAME[$record->country_code][$record->region] . "\n";
print $record->city . "\n";
print $record->postal_code . "\n";
print $record->latitude . "\n";
print $record->longitude . "\n";
print $record->metro_code . "\n";
print $record->area_code . "\n";
print $record->continent_code . "\n";
geoip_close($gi);


關(guān)于GeoIP庫怎么在php項(xiàng)目中運(yùn)用問題的解答就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識。


當(dāng)前文章:GeoIP庫怎么在php項(xiàng)目中運(yùn)用-創(chuàng)新互聯(lián)
文章位置:http://fisionsoft.com.cn/article/gjpoj.html