1. Go to this page and download the library: Download tourze/gb-t-2659 library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tourze / gb-t-2659 example snippets
use Tourze\GBT2659\Alpha2Code;
// Basic usage
$china = Alpha2Code::CN;
echo $china->value; // Output: CN
echo $china->getLabel(); // Output: 中国
echo $china->toLowerCase(); // Output: cn
// Create from string
$usa = Alpha2Code::from('US');
echo $usa->getLabel(); // Output: 美国
// Safe creation with tryFrom
$code = Alpha2Code::tryFrom('UK');
if ($code === null) {
echo "Invalid code";
}
// Get all countries
$allCountries = Alpha2Code::cases();
echo count($allCountries); // Output: 249