PHP Doku:: Negotiate clients preferred character set - function.http-negotiate-charset.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSonstige DiensteHTTPHTTP Funktionenhttp_negotiate_charset

Ein Service von Reinhard Neidl - Webprogrammierung.

HTTP Funktionen

<<http_support

http_negotiate_content_type>>

http_negotiate_charset

(PECL pecl_http >= 0.1.0)

http_negotiate_charsetNegotiate clients preferred character set

Beschreibung

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

This function negotiates the clients preferred charset based on its Accept-Charset HTTP header. The qualifier is recognized and charsets without qualifier are rated highest.

Parameter-Liste

supported

array containing the supported charsets as values

result

will be filled with an array containing the negotiation results

Rückgabewerte

Returns the negotiated charset or the default charset (i.e. first array entry) if none match.

Beispiele

Beispiel #1 Using http_negotiate_charset()

<?php
$charsets 
= array(
        
'iso-8859-1'// default
        
'iso-8859-2',
        
'iso-8859-15',
        
'utf-8'
);

$pref http_negotiate_charset($charsets$result);

if (
strcmp($pref'iso-8859-1')) {
        
iconv_set_encoding('internal_encoding''iso-8859-1');
        
iconv_set_encoding('output_encoding'$pref);
        
ob_start('ob_iconv_handler');
}

print_r($result);
?>


Keine BenutzerBeiträge.
- Beiträge aktualisieren...



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)