数据块 / countrycodes
国家代码和其他信息。
1.0.0
2019-12-15 14:41 UTC
This package is auto-updated.
Last update: 2024-09-16 01:44:30 UTC
README
安装
composer install datablock/countrycodes
用法
创建新实例
new CountryCodes([?string $country=null]);
参数
$country字符串 用于定义特定国家。
示例
use \Datablock\CountryCodes\CountryCodes; // ... $countrycodes = new CountryCodes(); $countrycodes = new CountryCodes('FR');
设置国家
定义或覆盖国家定义
$countrycodes->setCountry(string $country);
参数
$country字符串 (必需) 用于定义特定国家。
use \Datablock\CountryCodes\CountryCodes; // ... $countrycodes = new CountryCodes(); // ... $countrycodes->setCountry('FR');
数据库
获取PHP数组形式的数据库
- 如果未定义
$country,则getDatabase返回完整数据库。 - 如果定义了
$country,则getDatabase返回该国家的数据库。
$countrycodes->getDatabase([?string $country=null]);
getDatabase返回PHP数组形式的数据。getJsonDatabase返回JSON文件形式的数据。
参数
$country字符串 用于定义特定国家。
示例
-
示例 1(完整数据库)
use \Datablock\CountryCodes\CountryCodes; // ... $countrycodes = new CountryCodes(); // ... $countrycodes->getDatabase();
-
示例 2(实例上特定国家的数据库)
use \Datablock\CountryCodes\CountryCodes; // ... $countrycodes = new CountryCodes('FR'); // ... $countrycodes->getDatabase();
-
示例 3(实例后特定国家的数据库)
use \Datablock\CountryCodes\CountryCodes; // ... $countrycodes = new CountryCodes(); // ... $countrycodes->setCountry('FR'); // ... $countrycodes->getDatabase();
-
示例 4(仅方法上的特定国家数据库)
use \Datablock\CountryCodes\CountryCodes; // ... $countrycodes = new CountryCodes(); // ... $countrycodes->getDatabase('FR');
获取国家名称
- 如果未定义
$country,则getCountryName返回['country_code'] => "Country name"的关联数组。 - 如果定义了
$country,则getCountryName返回国家名称。
$countrycodes->getCountryName([?string $country=null]);
参数 & 示例:与 getDatabase 相同
获取ISO Alpha 2代码
- 如果未定义
$country,则getIso2返回['country_code'] => "Country ISO 2"的关联数组。 - 如果定义了
$country,则getIso2返回国家的ISO alpha 2代码。
$countrycodes->getIso2([?string $country=null]);
参数 & 示例:与 getDatabase 相同
获取ISO Alpha 3代码
- 如果未定义
$country,则getIso3返回['country_code'] => "Country ISO 3"的关联数组。 - 如果定义了
$country,则getIso3返回国家的ISO alpha 3代码。
$countrycodes->getIso3([?string $country=null]);
参数 & 示例:与 getDatabase 相同
获取TLD
- 如果未定义
$country,则getTld返回['country_code'] => "Country TLD"的关联数组。 - 如果定义了
$country,则getTld返回国家的TLD。
$countrycodes->getTld([?string $country=null]);
参数 & 示例:与 getDatabase 相同
获取FIPS代码
- 如果未定义
$country,则getFips返回['country_code'] => "Country FIPS"的关联数组。 - 如果定义了
$country,则getFips返回国家的FIPS代码。
$countrycodes->getFips([?string $country=null]);
参数 & 示例:与 getDatabase 相同
获取ISO数值代码
- 如果未定义
$country,则getIsoNumeric返回['country_code'] => "Country ISO Numeric"的关联数组。 - 如果定义了
$country,则getIsoNumeric返回国家的ISO数值代码。
$countrycodes->getIsoNumeric([?string $country=null]);
参数 & 示例:与 getDatabase 相同
获取geoname ID
- 如果未定义
$country,则getGeonameId返回['country_code'] => "Country Geoname ID"的关联数组。 - 如果定义了
$country,则getGeonameId返回国家的geoname ID。
$countrycodes->getGeonameId([?string $country=null]);
参数 & 示例:与 getDatabase 相同
获取E164
- 如果未定义
$country,则getE164返回['country_code'] => "Country E164"的关联数组。 - 如果定义了
$country,则getE164返回国家的E164。
$countrycodes->getE164([?string $country=null]);
参数 & 示例:与 getDatabase 相同
获取电话区号
- 如果未定义
$country,则getPhoneCode返回['country_code'] => "Country PhoneCode"的关联数组。 - 如果定义了
$country,则getPhoneCode返回国家的电话区号。
$countrycodes->getPhoneCode([?string $country=null]);
参数 & 示例:与 getDatabase 相同
获取大洲
- 如果未定义
$country,则getContinent返回关联数组['country_code'] => "Country Continent"。 - 如果已定义
$country,则getContinent返回该国家的洲。
$countrycodes->getContinent([?string $country=null]);
参数 & 示例:与 getDatabase 相同
获取首都
- 如果未定义
$country,则getCapital返回关联数组['country_code'] => "Country Capital"。 - 如果已定义
$country,则getCapital返回该国家的首都。
$countrycodes->getCapital([?string $country=null]);
参数 & 示例:与 getDatabase 相同
获取时区
- 如果未定义
$country,则getTimezone返回关联数组['country_code'] => "Country Timezone"。 - 如果已定义
$country,则getTimezone返回该国家的时区。
$countrycodes->getTimezone([?string $country=null]);
参数 & 示例:与 getDatabase 相同
获取货币
- 如果未定义
$country,则getCurrency返回关联数组['country_code'] => "Country Currency"。 - 如果已定义
$country,则getCurrency返回该国家的货币。
$countrycodes->getCurrency([?string $country=null]);
参数 & 示例:与 getDatabase 相同
获取语言代码
- 如果未定义
$country,则getLanguageCodes返回关联数组['country_code'] => "Country LanguageCodes"。 - 如果已定义
$country,则getLanguageCodes返回该国家的语言代码。
$countrycodes->getLanguageCodes([?string $country=null]);
参数 & 示例:与 getDatabase 相同
获取语言
- 如果未定义
$country,则getLanguages返回关联数组['country_code'] => "Country Languages"。 - 如果已定义
$country,则getLanguages返回该国家的语言。
$countrycodes->getLanguages([?string $country=null]);
参数 & 示例:与 getDatabase 相同
获取面积
- 如果未定义
$country,则getArea返回关联数组['country_code'] => "Country Area"。 - 如果已定义
$country,则getArea返回该国家的面积。
$countrycodes->getArea([?string $country=null]);
参数 & 示例:与 getDatabase 相同