API Documentation

Controller/Request/Http.php

Includes Classes 
category
Zend
copyright
Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
license
http://framework.zend.com/license/new-bsd New BSD License
package
Zend_Controller
version
$Id: Http.php 20984 2010-02-08 16:25:08Z matthew $
Classes
Zend_Controller_Request_Http

Description

Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.

Zend_Controller_Request_Http

Extends from
Zend_Controller_Request_Abstract
package
Zend_Controller
subpackage
Request
uses
Zend_Controller_Request_Abstract
Constants
SCHEME_HTTP
SCHEME_HTTPS
Properties
$_paramSources
$_requestUri
$_baseUrl
$_basePath
$_pathInfo
$_params
$_rawBody
$_aliases
Methods
__construct
__get
get
__set
set
__isset
has
setQuery
getQuery
setPost
getPost
getCookie
getServer
getEnv
setRequestUri
getRequestUri
setBaseUrl
getBaseUrl
setBasePath
getBasePath
setPathInfo
getPathInfo
setParamSources
getParamSources
setParam
getParam
getParams
setParams
setAlias
getAlias
getAliases
getMethod
isPost
isGet
isPut
isDelete
isHead
isOptions
isXmlHttpRequest
isFlashRequest
isSecure
getRawBody
getHeader
getScheme
getHttpHost
getClientIp

Description

Zend_Controller_Request_Http

HTTP request object for use with Zend_Controller family.

Constants

SCHEME_HTTP

 SCHEME_HTTP = 'http'

Scheme for http

Details

value
http

SCHEME_HTTPS

 SCHEME_HTTPS = 'https'

Scheme for https

Details

value
https

Properties

$_aliases

array $_aliases = 'array'

Alias keys for request parameters

Details

$_aliases
array
visibility
protected
default
array
final
false
static
false

$_basePath

string $_basePath = 'null'

Base path of request

Details

$_basePath
string
visibility
protected
default
null
final
false
static
false

$_baseUrl

string $_baseUrl = 'null'

Base URL of request

Details

$_baseUrl
string
visibility
protected
default
null
final
false
static
false

$_paramSources

array $_paramSources = 'array'

Allowed parameter sources

Details

$_paramSources
array
visibility
protected
default
array
final
false
static
false

$_params

array $_params = 'array'

Instance parameters

Details

$_params
array
visibility
protected
default
array
final
false
static
false

$_pathInfo

string $_pathInfo = ''

PATH_INFO

Details

$_pathInfo
string
visibility
protected
default
final
false
static
false

$_rawBody

string|false $_rawBody = ''

Raw request body

Details

$_rawBody
string|false
visibility
protected
default
final
false
static
false

$_requestUri

string; $_requestUri = ''

REQUEST_URI

Details

$_requestUri
string;
visibility
protected
default
final
false
static
false

Methods

__construct

__construct( string|Zend_Uri $uri = null ) : void

Constructor

If a $uri is passed, the object will attempt to populate itself using that information.

Arguments
$uri
stringZend_Uri
Details
visibility
public
final
false
static
false
throws
when invalid URI passed

__get

__get( string $key ) : mixed

Access values contained in the superglobals as public members Order of precedence: 1. GET, 2. POST, 3. COOKIE, 4. SERVER, 5. ENV

Arguments
$key
string
Output
mixed
Details
visibility
public
final
false
static
false
see
http://msdn.microsoft.com/en-us/library/system.web.httprequest.item.aspx

__isset

__isset( string $key ) : boolean

Check to see if a property is set

Arguments
$key
string
Output
boolean
Details
visibility
public
final
false
static
false

__set

__set( string $key, mixed $value ) : void

Set values

In order to follow {@link __get()}, which operates on a number of superglobals, setting values through overloading is not allowed and will raise an exception. Use setParam() instead.

Arguments
$key
string
$value
mixed
Details
visibility
public
final
false
static
false
throws

get

get( string $key ) : mixed

Alias to __get

Arguments
$key
string
Output
mixed
Details
visibility
public
final
false
static
false

getAlias

getAlias( string $name ) : string|null

Retrieve an alias

Retrieve the actual key represented by the alias $name.

Arguments
$name
string
Output
string|null
Returns null when no alias exists
Details
visibility
public
final
false
static
false

getAliases

getAliases( ) : array

Retrieve the list of all aliases

Output
array
Details
visibility
public
final
false
static
false

getBasePath

getBasePath( ) : string

Everything in REQUEST_URI before PATH_INFO not including the filename <img src="<?=$basePath?>/images/zend.png"/>

Output
string
Details
visibility
public
final
false
static
false

getBaseUrl

getBaseUrl( ) : string

Everything in REQUEST_URI before PATH_INFO <form action="<?=$baseUrl?>/news/submit" method="POST"/>

Output
string
Details
visibility
public
final
false
static
false

getClientIp

getClientIp( boolean $checkProxy = true ) : string

Get the client's IP addres

Arguments
$checkProxy
boolean
Output
string
Details
visibility
public
final
false
static
false

getCookie

getCookie( string $key = null, mixed $default = null ) : mixed

Retrieve a member of the $_COOKIE superglobal

If no $key is passed, returns the entire $_COOKIE array.

Arguments
$key
string
$default
mixed
Default value to use if key not found
Output
mixed
Returns null if key does not exist
Details
visibility
public
final
false
static
false
todo
How to retrieve from nested arrays

getEnv

getEnv( string $key = null, mixed $default = null ) : mixed

Retrieve a member of the $_ENV superglobal

If no $key is passed, returns the entire $_ENV array.

Arguments
$key
string
$default
mixed
Default value to use if key not found
Output
mixed
Returns null if key does not exist
Details
visibility
public
final
false
static
false

getHeader

getHeader( string $header ) : string|false

Return the value of the given HTTP header. Pass the header name as the plain, HTTP-specified header name. Ex.: Ask for 'Accept' to get the Accept header, 'Accept-Encoding' to get the Accept-Encoding header.

Arguments
$header
string
HTTP header name
Output
string|false
HTTP header value, or false if not found
Details
visibility
public
final
false
static
false
throws

getHttpHost

getHttpHost( ) : string

Get the HTTP host.

"Host" ":" host [ ":" port ] ; Section 3.2.2 Note the HTTP Host header is not the same as the URI host. It includes the port while the URI host doesn't.

Output
string
Details
visibility
public
final
false
static
false

getMethod

getMethod( ) : string

Return the method by which the request was made

Output
string
Details
visibility
public
final
false
static
false

getParam

getParam( mixed $key, mixed $default = null ) : mixed

Retrieve a parameter

Retrieves a parameter from the instance. Priority is in the order of userland parameters (see {@link setParam()}), $_GET, $_POST. If a parameter matching the $key is not found, null is returned.

If the $key is an alias, the actual key aliased will be used.

Arguments
$key
mixed
$default
mixed
Default value to use if key not found
Output
mixed
Details
visibility
public
final
false
static
false

getParamSources

getParamSources( ) : array

Get list of allowed parameter sources

Output
array
Details
visibility
public
final
false
static
false

getParams

getParams( ) : array

Retrieve an array of parameters

Retrieves a merged array of parameters, with precedence of userland params (see {@link setParam()}), $_GET, $_POST (i.e., values in the userland params will take precedence over all others).

Output
array
Details
visibility
public
final
false
static
false

getPathInfo

getPathInfo( ) : string

Returns everything between the BaseUrl and QueryString.

This value is calculated instead of reading PATH_INFO directly from $_SERVER due to cross-platform differences.

Output
string
Details
visibility
public
final
false
static
false

getPost

getPost( string $key = null, mixed $default = null ) : mixed

Retrieve a member of the $_POST superglobal

If no $key is passed, returns the entire $_POST array.

Arguments
$key
string
$default
mixed
Default value to use if key not found
Output
mixed
Returns null if key does not exist
Details
visibility
public
final
false
static
false
todo
How to retrieve from nested arrays

getQuery

getQuery( string $key = null, mixed $default = null ) : mixed

Retrieve a member of the $_GET superglobal

If no $key is passed, returns the entire $_GET array.

Arguments
$key
string
$default
mixed
Default value to use if key not found
Output
mixed
Returns null if key does not exist
Details
visibility
public
final
false
static
false
todo
How to retrieve from nested arrays

getRawBody

getRawBody( ) : string|false

Return the raw body of the request, if present

Output
string|false
Raw body, or false if not present
Details
visibility
public
final
false
static
false

getRequestUri

getRequestUri( ) : string

Returns the REQUEST_URI taking into account platform differences between Apache and IIS

Output
string
Details
visibility
public
final
false
static
false

getScheme

getScheme( ) : string

Get the request URI scheme

Output
string
Details
visibility
public
final
false
static
false

getServer

getServer( string $key = null, mixed $default = null ) : mixed

Retrieve a member of the $_SERVER superglobal

If no $key is passed, returns the entire $_SERVER array.

Arguments
$key
string
$default
mixed
Default value to use if key not found
Output
mixed
Returns null if key does not exist
Details
visibility
public
final
false
static
false

has

has( string $key ) : boolean

Alias to __isset()

Arguments
$key
string
Output
boolean
Details
visibility
public
final
false
static
false

isDelete

isDelete( ) : boolean

Was the request made by DELETE?

Output
boolean
Details
visibility
public
final
false
static
false

isFlashRequest

isFlashRequest( ) : boolean

Is this a Flash request?

Output
boolean
Details
visibility
public
final
false
static
false

isGet

isGet( ) : boolean

Was the request made by GET?

Output
boolean
Details
visibility
public
final
false
static
false

isHead

isHead( ) : boolean

Was the request made by HEAD?

Output
boolean
Details
visibility
public
final
false
static
false

isOptions

isOptions( ) : boolean

Was the request made by OPTIONS?

Output
boolean
Details
visibility
public
final
false
static
false

isPost

isPost( ) : boolean

Was the request made by POST?

Output
boolean
Details
visibility
public
final
false
static
false

isPut

isPut( ) : boolean

Was the request made by PUT?

Output
boolean
Details
visibility
public
final
false
static
false

isSecure

isSecure( ) : boolean

Is https secure request

Output
boolean
Details
visibility
public
final
false
static
false

isXmlHttpRequest

isXmlHttpRequest( ) : boolean

Is the request a Javascript XMLHttpRequest?

Should work with Prototype/Script.aculo.us, possibly others.

Output
boolean
Details
visibility
public
final
false
static
false

set

set( string $key, mixed $value ) : void

Alias to __set()

Arguments
$key
string
$value
mixed
Details
visibility
public
final
false
static
false

setAlias

setAlias( string $name, string $target ) : Zend_Controller_Request_Http

Set a key alias

Set an alias used for key lookups. $name specifies the alias, $target specifies the actual key to use.

Arguments
$name
string
$target
string
Details
visibility
public
final
false
static
false

setBasePath

setBasePath( string|null $basePath = null ) : Zend_Controller_Request_Http

Set the base path for the URL

Arguments
$basePath
stringnull
Details
visibility
public
final
false
static
false

setBaseUrl

setBaseUrl( mixed $baseUrl = null ) : Zend_Controller_Request_Http

Set the base URL of the request; i.e., the segment leading to the script name

E.g.: - /admin - /myapp - /subdir/index.php

Do not use the full URI when providing the base. The following are examples of what not to use: - http://example.com/admin (should be just /admin) - http://example.com/subdir/index.php (should be just /subdir/index.php)

If no $baseUrl is provided, attempts to determine the base URL from the environment, using SCRIPT_FILENAME, SCRIPT_NAME, PHP_SELF, and ORIG_SCRIPT_NAME in its determination.

Arguments
$baseUrl
mixed
Details
visibility
public
final
false
static
false

setParam

setParam( mixed $key, mixed $value ) : Zend_Controller_Request_Http

Set a userland parameter

Uses $key to set a userland parameter. If $key is an alias, the actual key will be retrieved and used to set the parameter.

Arguments
$key
mixed
$value
mixed
Details
visibility
public
final
false
static
false

setParamSources

setParamSources(  $paramSources = array ) : Zend_Controller_Request_Http

Set allowed parameter sources

Can be empty array, or contain one or more of '_GET' or '_POST'.

Arguments
$paramSources
Details
visibility
public
final
false
static
false

setParams

setParams( array $params ) : Zend_Controller_Request_Http

Set parameters

Set one or more parameters. Parameters are set as userland parameters, using the keys specified in the array.

Arguments
$params
array
Details
visibility
public
final
false
static
false

setPathInfo

setPathInfo( string|null $pathInfo = null ) : Zend_Controller_Request_Http

Set the PATH_INFO string

Arguments
$pathInfo
stringnull
Details
visibility
public
final
false
static
false

setPost

setPost( string|array $spec, null|mixed $value = null ) : Zend_Controller_Request_Http

Set POST values

Arguments
$spec
stringarray
$value
nullmixed
Details
visibility
public
final
false
static
false

setQuery

setQuery( string|array $spec, null|mixed $value = null ) : Zend_Controller_Request_Http

Set GET values

Arguments
$spec
stringarray
$value
nullmixed
Details
visibility
public
final
false
static
false

setRequestUri

setRequestUri( string $requestUri = null ) : Zend_Controller_Request_Http

Set the REQUEST_URI on which the instance operates

If no request URI is passed, uses the value in $_SERVER['REQUEST_URI'], $_SERVER['HTTP_X_REWRITE_URL'], or $_SERVER['ORIG_PATH_INFO'] + $_SERVER['QUERY_STRING'].

Arguments
$requestUri
string
Details
visibility
public
final
false
static
false
Documentation was generated by DocBlox.