= 0.2.0)geoip_country_name_by_name — 獲取國(guó)家的全稱說明geoip_country_name_by_name(string $hostname): stringgeoip_country">
(PECL geoip >= 0.2.0)
geoip_country_name_by_name — 獲取國(guó)家的全稱
$hostname
): stringgeoip_country_name_by_name() 函數(shù)返回主機(jī)或者 IP 地址所對(duì)應(yīng)的國(guó)家名全稱。
hostname
定位所用的主機(jī)或者 IP 地址。
成功,返回國(guó)家全稱,如果在數(shù)據(jù)庫中未找到相關(guān)信息則返回 false
。
示例 #1 geoip_country_name_by_name() 函數(shù)的使用范例:
以下代碼將會(huì)打印 example.com 主機(jī)的定位信息。
<?php
$country = geoip_country_name_by_name('www.example.com');
if ($country) {
echo 'This host is located in: ' . $country;
}
?>
以上例程會(huì)輸出:
This host is located in: United States