Zend Framework  1.12
Public Member Functions | Public Attributes | Protected Attributes | List of all members
Zend_Controller_Request_Http Class Reference

Public Member Functions

 __construct ($uri=null)
 Constructor.
 
 __get ($key)
 Access values contained in the superglobals as public members Order of precedence: 1.
 
 get ($key)
 Alias to __get.
 
 __set ($key, $value)
 Set values.
 
 set ($key, $value)
 Alias to __set()
 
 __isset ($key)
 Check to see if a property is set.
 
 has ($key)
 Alias to __isset()
 
 setQuery ($spec, $value=null)
 Set GET values.
 
 getQuery ($key=null, $default=null)
 Retrieve a member of the $_GET superglobal.
 
 setPost ($spec, $value=null)
 Set POST values.
 
 getPost ($key=null, $default=null)
 Retrieve a member of the $_POST superglobal.
 
 getCookie ($key=null, $default=null)
 Retrieve a member of the $_COOKIE superglobal.
 
 getServer ($key=null, $default=null)
 Retrieve a member of the $_SERVER superglobal.
 
 getEnv ($key=null, $default=null)
 Retrieve a member of the $_ENV superglobal.
 
 setRequestUri ($requestUri=null)
 Set the REQUEST_URI on which the instance operates.
 
 getRequestUri ()
 Returns the REQUEST_URI taking into account platform differences between Apache and IIS.
 
 setBaseUrl ($baseUrl=null)
 Set the base URL of the request; i.e., the segment leading to the script name.
 
 getBaseUrl ($raw=false)
 Everything in REQUEST_URI before PATH_INFO <form action="<?=$baseUrl?>/news/submit" method="POST">
 
 setBasePath ($basePath=null)
 Set the base path for the URL.
 
 getBasePath ()
 Everything in REQUEST_URI before PATH_INFO not including the filename.
 
 setPathInfo ($pathInfo=null)
 Set the PATH_INFO string.
 
 getPathInfo ()
 Returns everything between the BaseUrl and QueryString.
 
 setParamSources (array $paramSources=array())
 Set allowed parameter sources.
 
 getParamSources ()
 Get list of allowed parameter sources.
 
 setParam ($key, $value)
 Set a userland parameter.
 
 getParam ($key, $default=null)
 Retrieve a parameter.
 
 getParams ()
 Retrieve an array of parameters.
 
 setParams (array $params)
 Set parameters.
 
 setAlias ($name, $target)
 Set a key alias.
 
 getAlias ($name)
 Retrieve an alias.
 
 getAliases ()
 Retrieve the list of all aliases.
 
 getMethod ()
 Return the method by which the request was made.
 
 isPost ()
 Was the request made by POST?
 
 isGet ()
 Was the request made by GET?
 
 isPut ()
 Was the request made by PUT?
 
 isDelete ()
 Was the request made by DELETE?
 
 isHead ()
 Was the request made by HEAD?
 
 isOptions ()
 Was the request made by OPTIONS?
 
 isXmlHttpRequest ()
 Is the request a Javascript XMLHttpRequest?
 
 isFlashRequest ()
 Is this a Flash request?
 
 isSecure ()
 Is https secure request.
 
 getRawBody ()
 Return the raw body of the request, if present.
 
 getHeader ($header)
 Return the value of the given HTTP header.
 
 getScheme ()
 Get the request URI scheme.
 
 getHttpHost ()
 Get the HTTP host.
 
 getClientIp ($checkProxy=true)
 Get the client's IP addres.
 
- Public Member Functions inherited from Zend_Controller_Request_Abstract
 getModuleName ()
 Retrieve the module name.
 
 setModuleName ($value)
 Set the module name to use.
 
 getControllerName ()
 Retrieve the controller name.
 
 setControllerName ($value)
 Set the controller name to use.
 
 getActionName ()
 Retrieve the action name.
 
 setActionName ($value)
 Set the action name.
 
 getModuleKey ()
 Retrieve the module key.
 
 setModuleKey ($key)
 Set the module key.
 
 getControllerKey ()
 Retrieve the controller key.
 
 setControllerKey ($key)
 Set the controller key.
 
 getActionKey ()
 Retrieve the action key.
 
 setActionKey ($key)
 Set the action key.
 
 getParam ($key, $default=null)
 Get an action parameter.
 
 getUserParams ()
 Retrieve only user params (i.e, any param specific to the object and not the environment)
 
 getUserParam ($key, $default=null)
 Retrieve a single user param (i.e, a param specific to the object and not the environment)
 
 setParam ($key, $value)
 Set an action parameter.
 
 getParams ()
 Get all action parameters.
 
 setParams (array $array)
 Set action parameters en masse; does not overwrite.
 
 clearParams ()
 Unset all user parameters.
 
 setDispatched ($flag=true)
 Set flag indicating whether or not request has been dispatched.
 
 isDispatched ()
 Determine if the request has been dispatched.
 

Public Attributes

const SCHEME_HTTP = 'http'
 Scheme for http.
 
const SCHEME_HTTPS = 'https'
 Scheme for https.
 

Protected Attributes

 $_paramSources = array('_GET', '_POST')
 
 $_requestUri
 
 $_baseUrl = null
 
 $_basePath = null
 
 $_pathInfo = ''
 
 $_params = array()
 
 $_rawBody
 
 $_aliases = array()
 
- Protected Attributes inherited from Zend_Controller_Request_Abstract
 $_dispatched = false
 
 $_module
 
 $_moduleKey = 'module'
 
 $_controller
 
 $_controllerKey = 'controller'
 
 $_action
 
 $_actionKey = 'action'
 
 $_params = array()
 

Constructor & Destructor Documentation

__construct (   $uri = null)

Constructor.

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

Parameters
string | Zend_Uri$uri
Returns
void
Exceptions
Zend_Controller_Request_Exceptionwhen invalid URI passed

Member Function Documentation

__get (   $key)

Access values contained in the superglobals as public members Order of precedence: 1.

GET, 2. POST, 3. COOKIE, 4. SERVER, 5. ENV

See Also
http://msdn.microsoft.com/en-us/library/system.web.httprequest.item.aspx
Parameters
string$key
Returns
mixed
__isset (   $key)

Check to see if a property is set.

Parameters
string$key
Returns
boolean
__set (   $key,
  $value 
)

Set values.

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

Parameters
string$key
mixed$value
Returns
void
Exceptions
Zend_Controller_Request_Exception
get (   $key)

Alias to __get.

Parameters
string$key
Returns
mixed
getAlias (   $name)

Retrieve an alias.

Retrieve the actual key represented by the alias $name.

Parameters
string$name
Returns
string|null Returns null when no alias exists
getAliases ( )

Retrieve the list of all aliases.

Returns
array
getBasePath ( )

Everything in REQUEST_URI before PATH_INFO not including the filename.

Returns
string
getBaseUrl (   $raw = false)

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

Returns
string
getClientIp (   $checkProxy = true)

Get the client's IP addres.

Parameters
boolean$checkProxy
Returns
string
getCookie (   $key = null,
  $default = null 
)

Retrieve a member of the $_COOKIE superglobal.

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

Todo:
How to retrieve from nested arrays
Parameters
string$key
mixed$defaultDefault value to use if key not found
Returns
mixed Returns null if key does not exist
getEnv (   $key = null,
  $default = null 
)

Retrieve a member of the $_ENV superglobal.

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

Parameters
string$key
mixed$defaultDefault value to use if key not found
Returns
mixed Returns null if key does not exist
getHeader (   $header)

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.

Parameters
string$headerHTTP header name
Returns
string|false HTTP header value, or false if not found
Exceptions
Zend_Controller_Request_Exception
getHttpHost ( )

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.

Returns
string
getMethod ( )

Return the method by which the request was made.

Returns
string
getParam (   $key,
  $default = null 
)

Retrieve a parameter.

Retrieves a parameter from the instance. Priority is in the order of userland parameters (see 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.

Parameters
mixed$key
mixed$defaultDefault value to use if key not found
Returns
mixed
getParams ( )

Retrieve an array of parameters.

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

Returns
array
getParamSources ( )

Get list of allowed parameter sources.

Returns
array
getPathInfo ( )

Returns everything between the BaseUrl and QueryString.

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

Returns
string
getPost (   $key = null,
  $default = null 
)

Retrieve a member of the $_POST superglobal.

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

Todo:
How to retrieve from nested arrays
Parameters
string$key
mixed$defaultDefault value to use if key not found
Returns
mixed Returns null if key does not exist
getQuery (   $key = null,
  $default = null 
)

Retrieve a member of the $_GET superglobal.

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

Todo:
How to retrieve from nested arrays
Parameters
string$key
mixed$defaultDefault value to use if key not found
Returns
mixed Returns null if key does not exist
getRawBody ( )

Return the raw body of the request, if present.

Returns
string|false Raw body, or false if not present
getRequestUri ( )

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

Returns
string
getScheme ( )

Get the request URI scheme.

Returns
string
getServer (   $key = null,
  $default = null 
)

Retrieve a member of the $_SERVER superglobal.

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

Parameters
string$key
mixed$defaultDefault value to use if key not found
Returns
mixed Returns null if key does not exist
has (   $key)

Alias to __isset()

Parameters
string$key
Returns
boolean
isDelete ( )

Was the request made by DELETE?

Returns
boolean
isFlashRequest ( )

Is this a Flash request?

Returns
boolean
isGet ( )

Was the request made by GET?

Returns
boolean
isHead ( )

Was the request made by HEAD?

Returns
boolean
isOptions ( )

Was the request made by OPTIONS?

Returns
boolean
isPost ( )

Was the request made by POST?

Returns
boolean
isPut ( )

Was the request made by PUT?

Returns
boolean
isSecure ( )

Is https secure request.

Returns
boolean
isXmlHttpRequest ( )

Is the request a Javascript XMLHttpRequest?

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

Returns
boolean
set (   $key,
  $value 
)

Alias to __set()

Parameters
string$key
mixed$value
Returns
void
setAlias (   $name,
  $target 
)

Set a key alias.

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

Parameters
string$name
string$target
Returns
Zend_Controller_Request_Http
setBasePath (   $basePath = null)

Set the base path for the URL.

Parameters
string | null$basePath
Returns
Zend_Controller_Request_Http
setBaseUrl (   $baseUrl = null)

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:

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.

Parameters
mixed$baseUrl
Returns
Zend_Controller_Request_Http
setParam (   $key,
  $value 
)

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.

Parameters
mixed$key
mixed$value
Returns
Zend_Controller_Request_Http
setParams ( array  $params)

Set parameters.

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

Parameters
array$params
Returns
Zend_Controller_Request_Http
setParamSources ( array  $paramSources = array())

Set allowed parameter sources.

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

Parameters
array$paramSoures
Returns
Zend_Controller_Request_Http
setPathInfo (   $pathInfo = null)

Set the PATH_INFO string.

Parameters
string | null$pathInfo
Returns
Zend_Controller_Request_Http
setPost (   $spec,
  $value = null 
)

Set POST values.

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

Set GET values.

Parameters
string | array$spec
null | mixed$value
Returns
Zend_Controller_Request_Http
setRequestUri (   $requestUri = null)

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'].

Parameters
string$requestUri
Returns
Zend_Controller_Request_Http

Member Data Documentation

$_aliases = array()
protected
$_basePath = null
protected
$_baseUrl = null
protected
$_params = array()
protected
$_paramSources = array('_GET', '_POST')
protected
$_pathInfo = ''
protected
$_rawBody
protected
$_requestUri
protected
const SCHEME_HTTP = 'http'

Scheme for http.

const SCHEME_HTTPS = 'https'

Scheme for https.