HTTP

HTTP -- HTTP utility class

Synopsis

require_once "HTTP.php";

Description

HTTP utility functions.

HTTP::date

string HTTP::date (integer time)

Format a RFC compliant HTTP header. This function honors the "y2k_compliance" php.ini directive.

The parameter time has to be a UNIX timestamp that is converted to an RFC compliant date, which is returned by the function.

HTTP::negotiateLanguage

string HTTP::negotiateLanguage (array supported, string default)

Negotiate language with the user's browser through the Accept-Language HTTP header or the user's host address. Language codes are generally in the form "ll" for a language spoken in only one country, or "ll-CC" for a language spoken in a particular country. For example, U.S. English is "en-US", while British English is "en-UK". Portugese as spoken in Portugal is "pt-PT", while Brazilian Portugese is "pt-BR". Two-letter country codes can be found in the ISO 3166 standard.

Quantities in the Accept-Language: header are supported, for example:

Accept-Language: en-UK;q=0.7, en-US;q=0.6, no;q=1.0, dk;q=0.8

The first parameter supported is an associative array indexed by language codes (country codes) supported by the application. Values must evaluate to true.

The second parameter default is the default language that should be used when if none of the other languages is found during negotiation. The default value for this parameter is "en-US" for U.S. English.