Locale::getPrimaryLanguage

locale_get_primary_language

(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL intl >= 1.0.0)

Locale::getPrimaryLanguage -- locale_get_primary_languageLit la langue principale de la locale

Description

Style orienté objet

publicstaticLocale::getPrimaryLanguage(string$locale): ?string

Style procédural

locale_get_primary_language(string$locale): ?string

Lit la langue principale de la locale.

Liste de paramètres

locale

La locale dont il faut extraire la langue principale.

Valeurs de retour

Le code de langue, associé à la langue.

Retourne null quand la longueur de locale excède INTL_MAX_LOCALE_LEN.

Exemples

Exemple #1 Exemple avec locale_get_primary_language(), procédural

<?php
echo locale_get_primary_language('zh-Hant');
?>

Exemple #2 Exemple avec locale_get_primary_language(), POO

<?php
echo Locale::getPrimaryLanguage('zh-Hant');
?>

L'exemple ci-dessus va afficher :

zh

Voir aussi

To Top