PHP Velho Oeste 2024

http_negotiate_language

(PECL pecl_http >= 0.1.0)

http_negotiate_languageNégocie le langage préféré par les clients

Description

string http_negotiate_language ( array $supported [, array &$result ] )

Cette fonction négocie le langage préféré par les clients, basé sur les en-têtes HTTP Accept-Language.

Liste de paramètres

supported

tableau contenant les langages supportés en tant que valeurs

result

contient un tableau, contenant les résultats de la négociation

Valeurs de retour

Retourne le langage négocié ou le langage par défaut (i.e. première entrée du tableau) si aucun ne correspond.

Exemples

Exemple #1 Exemple avec http_negotiate_language()

<?php
$langs 
= array(
    
'en-US',// défaut
    
'fr',
    
'fr-FR',
    
'de',
    
'de-DE',
    
'de-AT',
    
'de-CH',
);

include 
'./langs/'http_negotiate_language($langs$result) .'.php';

print_r($result);
?>

add a note add a note

User Contributed Notes 1 note

up
0
Mahn
9 years ago
This method can be found as http\Env::negotiateLanguage in the http pecl module version 2, see here: http://devel-m6w6.rhcloud.com/mdref/http/Env/negotiateLanguage
To Top