HTTP
[ class tree: HTTP ] [ index: HTTP ] [ all elements ]

Class: HTTP

Source Location: /HTTP-1.3.0RC1/HTTP.php

Class Overview


HTTP


Author(s):

Version:

  • $Revision: 1.26 $

Methods


Inherited Variables

Inherited Methods


Class Details

[line 37]
HTTP

HTTP utility functions

  • Version: $Revision: 1.26 $
  • Access: public


[ Top ]


Method Detail

absoluteURI   [line 260]

string absoluteURI( string $url, [string $protocol = null], [integer $port = null])

Absolute URI

This function returns the absolute URI for the partial URL passed. The current scheme (HTTP/HTTPS), host server, port, current script location are used if necessary to resolve any relative URLs.

Offsets potentially created by PATH_INFO are taken care of to resolve relative URLs to the current script.

You can choose a new protocol while resolving the URI. This is particularly useful when redirecting a web browser using relative URIs and to switch from HTTP to HTTPS, or vice-versa, at the same time.


Parameters:

string   $url   —  Absolute or relative URI the redirect should go to.
string   $protocol   —  Protocol to use when redirecting URIs.
integer   $port   —  A new port number.

[ Top ]

Date   [line 51]

mixed Date( [mixed $time = null])

Date

Format a RFC compliant GMT date HTTP header. This function honors the "y2k_compliance" php.ini directive and formats the GMT date corresponding to either RFC850 or RFC822.

  • Return: GMT date string, or false for an invalid $time parameter
  • Access: public

Parameters:

mixed   $time   —  unix timestamp or date (default = current time)

[ Top ]

head   [line 169]

mixed head( string $url, [integer $timeout = 10])

Head

Sends a "HEAD" HTTP command to a server and returns the headers as an associative array. Example output could be:

  1.      Array
  2.      (
  3.          [response_code=> 200          // The HTTP response code
  4.          [response=> HTTP/1.1 200 OK   // The full HTTP response string
  5.          [Date=> Fri11 Jan 2002 01:41:44 GMT
  6.          [Server=> Apache/1.3.20 (UnixPHP/4.1.1
  7.          [X-Powered-By=> PHP/4.1.1
  8.          [Connection=> close
  9.          [Content-Type=> text/html
  10.      )

  • Return: Returns associative array of response headers on success or PEAR error on failure.
  • See: HTTP_Client::head()
  • See: HTTP_Request
  • Access: public

Parameters:

string   $url   —  A valid URL, e.g.: http://pear.php.net/credits.php
integer   $timeout   —  Timeout in seconds (default = 10)

[ Top ]

negotiateLanguage   [line 99]

string negotiateLanguage( array $supported, [string $default = 'en-US'])

Negotiate Language

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".

Quality factors in the Accept-Language: header are supported, e.g.: Accept-Language: en-UK;q=0.7, en-US;q=0.6, no, dk;q=0.8

  1.   require_once 'HTTP.php';
  2.   $langs = array(
  3.       'en'   => 'locales/en',
  4.       'en-US'=> 'locales/en',
  5.       'en-UK'=> 'locales/en',
  6.       'de'   => 'locales/de',
  7.       'de-DE'=> 'locales/de',
  8.       'de-AT'=> 'locales/de',
  9.   );
  10.   $neg HTTP::negotiateLanguage($langs);
  11.   $dir $langs[$neg];

  • Return: The negotiated language result or the supplied default.
  • Access: public

Parameters:

array   $supported   —  An associative array of supported languages, whose values must evaluate to true.
string   $default   —  The default language to use if none is found.

[ Top ]

raiseError   [line 318]

object PEAR_Error raiseError( [mixed $error = null], [int $code = null])

Raise Error

Lazy raising of PEAR_Errors.

  • Access: protected

Parameters:

mixed   $error   — 
int   $code   — 

[ Top ]

redirect   [line 224]

mixed redirect( string $url, [bool $exit = true])

Redirect

This function redirects the client. This is done by issuing a "Location" header and exiting if wanted.

  • Return: Returns true on succes (or exits) or false if headers have already been sent.
  • Access: public

Parameters:

string   $url   —  URL where the redirect should go to.
bool   $exit   —  Whether to exit immediately after redirection.

[ Top ]


Documentation generated on Mon, 11 Mar 2019 10:17:27 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.