chibifr/country-converter
最新稳定版本:1.0.0
Composer 安装命令:
composer require chibifr/country-converter
包简介
A PHP package to convert a country ISO to country name and vice-versa.
README 文档
README
A PHP package to convert a country ISO to country name and vice-versa.
Installation
To install this package, make sure you have composer. Then, require it:
composer require chibifr/country-converter
Usage
You can now use it really easily! After you required the package with composer, start using it:
Without Exception management
<?php // Require the composer's vendor autoload file require './vendor/autoload.php'; use ChibiFR\CountryConverter\Converter; // Create a new Converter object $converter = new Converter(); // Get a country name from its ISO code echo $converter->getCountryName('jp'); // will echo "Japan" // Get a country ISO code from its name echo $converter->getCountryCode('France'); // will echo "FR"
With Exception management
<?php // Require the composer's vendor autoload file require './vendor/autoload.php'; use ChibiFR\CountryConverter\Converter; // Create a new Converter object $converter = new Converter(); // Get a country name from its ISO code try { echo $converter->getCountryName('jp'); // will echo "Japan" } catch (InvalidCountryNameException $e) { die($e->getMessage()); } // Get a country ISO code from its name try { echo $converter->getCountryCode('France'); // will echo "FR" } catch (InvalidCountryCodeException $e) { die($e->getMessage()); }
统计信息
- 总下载量: 3.63k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-11-15