array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'fr', ), 'this' => array ( 0 => 'locale.acceptfromhttp.php', 1 => 'Locale::acceptFromHttp', ), 'up' => array ( 0 => 'class.locale.php', 1 => 'Locale', ), 'prev' => array ( 0 => 'class.locale.php', 1 => 'Locale', ), 'next' => array ( 0 => 'locale.canonicalize.php', 1 => 'Locale::canonicalize', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'fr', 'path' => 'reference/intl/locale/accept-from-http.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL intl >= 1.0.0)
Locale::acceptFromHttp -- locale_accept_from_http — Devine la meilleure locale à partir de l'en-tête HTTP "Accept-Language"
Style orienté objet
Style procédural
Essaie de trouver une locale qui peut satisfaire la liste de langue qui est
demandée par l'en-tête HTTP "Accept-Language"
.
header
La chaîne contenant l'en-tête "Accept-Language"
,
au format de la RFC 2616.
L'identifiant de locale correspondant.
Retourne false
quand la longueur de header
dépasse
INTL_MAX_LOCALE_LEN
.
Exemple #1 Exemple avec locale_accept_from_http(), procédural
<?php
$locale = locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']);
echo $locale;
?>
Exemple #2 Exemple avec locale_accept_from_http(), POO
<?php
$locale = Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);
echo $locale;
?>
L'exemple ci-dessus va afficher :
en_US