mlocati/countrynames

一个用于处理本地化国家名称的PHP库

1.0.0 2016-11-21 15:09 UTC

This package is auto-updated.

Last update: 2024-09-13 04:34:21 UTC


README

特性

  • 支持多种语言(几乎有150种,但某些语言可能不完整)。
  • 支持PHP 5.3及以上版本
  • 需要mb_string PHP扩展(或任何实现mb_strtolower的UTF-8包)

安装

使用composer

composer require mlocati/countrynames

不使用composer

<?php

require_once 'autoload.php';

示例用法

use MLocati\CountryNames\CountryList;

require_once 'autoload.php'; // Not required if you use composer

$italianList = new CountryList('it');
$italianCountry = $italianList->getCountryByName('italia');

$englishList = new CountryList('en');
$englishCountry = $englishList->getCountryByCode($italianCountry->getCode());

echo $englishCountry->getCanonicalName(); // Dumps 'Italy'