= 0.2.0)geoip_country_code_by_name — 獲取國家代碼說明geoip_country_code_by_name(string $hostname): stringgeoip_country_">

geoip_country_code_by_name

(PECL geoip >= 0.2.0)

geoip_country_code_by_name獲取國家代碼

說明

geoip_country_code_by_name(string $hostname): string

geoip_country_code_by_name() 函數(shù)將會返回主機或者IP地址所在的國家代碼。

參數(shù)

hostname

定位的主機名或者IP地址。

返回值

成功,返回 ISO 定義的國家代碼,如果在數(shù)據(jù)庫中未找到相關(guān)信息則返回 false

范例

示例 #1 geoip_country_code_by_name() 函數(shù)的范例:

以下代碼將會打印 example.com 主機的定位信息。

<?php
$country 
geoip_country_code_by_name('www.example.com');
if (
$country) {
    echo 
'This host is located in: ' $country;
}
?>

以上例程會輸出:

This host is located in: US

注釋

警告

請點擊 ? http://www.maxmind.com/en/iso3166 來查看所有可能的返回值列表,包括特殊代碼。

參見