JRequest
JRequest Class
This class serves to provide the Joomla Platform with a common interface to access request variables. This includes $_POST, $_GET, and naturally $_REQUEST. Variables can be passed through an input filter to avoid injection or returned raw.
| package | Joomla.Platform | 
|---|---|
| subpackage | Environment | 
| since | 11.1 | 
| deprecated | 12.1 Get the JInput object from the application instead | 
Methods
_cleanVar
Clean up an input variable.
_cleanVar(mixed $var, integer $mask, string $type = null) : mixed
| deprecated | 12.1 | 
|---|---|
| since | 11.1 | 
Arguments
- $var
- mixedThe input variable.
- $mask
- integerFilter bit mask. 1 = no trim: If this flag is cleared and the input is a string, the string will have leading and trailing whitespace trimmed. 2 = allow_raw: If set, no more filtering is performed, higher bits are ignored. 4 = allow_html: HTML is allowed, but passed through a safe HTML filter first. If set, no more filtering is performed. If no bits other than the 1 bit is set, a strict filter is applied.
- $type
- stringThe variable type {@see JFilterInput::clean()}.
Response
mixedSame as $var
_stripSlashesRecursive
Strips slashes recursively on an array.
_stripSlashesRecursive(array $value) : array
| deprecated | 12.1 | 
|---|---|
| since | 11.1 | 
Arguments
- $value
- arrayArray or (nested arrays) of strings.
Response
arrayThe input array with stripslashes applied to it.
checkToken
Checks for a form token in the request.
checkToken(string $method = 'post') : boolean
Use in conjunction with JHtml::_('form.token').
| deprecated | 12.1 Use JSession::checkToken() instead. | 
|---|---|
| since | 11.1 | 
Arguments
- $method
- stringThe request method in which to look for the token key.
Response
booleanTrue if found and valid, false otherwise.
clean
Cleans the request from script injection.
clean() : void
| since | 11.1 | 
|---|---|
| deprecated | 12.1 | 
get
Fetches and returns a request array.
get(string $hash = 'default', integer $mask) : mixed
The default behaviour is fetching variables depending on the current request method: GET and HEAD will result in returning $_GET, POST and PUT will result in returning $_POST.
You can force the source by setting the $hash parameter:
post $_POST get $_GET files $_FILES cookie $_COOKIE env $_ENV server $_SERVER method via current $_SERVER['REQUEST_METHOD'] default $_REQUEST
| deprecated | 12.1 User JInput::get | 
|---|---|
| see | \JInput | 
| since | 11.1 | 
Arguments
- $hash
- stringto get (POST, GET, FILES, METHOD).
- $mask
- integerFilter mask for the variable.
Response
mixedRequest hash.
getBool
Fetches and returns a given filtered variable. The bool filter will only return true/false bool values. This is currently only a proxy function for getVar().
getBool(string $name, string $default = false, string $hash = 'default') : boolean
See getVar() for more in-depth documentation on the parameters.
| deprecated | 12.1 | 
|---|---|
| since | 11.1 | 
Arguments
- $name
- stringVariable name.
- $default
- stringDefault value if the variable does not exist.
- $hash
- stringWhere the var should come from (POST, GET, FILES, COOKIE, METHOD).
Response
booleanRequested variable.
getCmd
Cmd (Word and Integer0 filter
getCmd(string $name, string $default = '', string $hash = 'default') : string
Fetches and returns a given filtered variable. The cmd filter only allows the characters [A-Za-z0-9.-_]. This is currently only a proxy function for getVar().
See getVar() for more in-depth documentation on the parameters.
| deprecated | 12.1 | 
|---|---|
| since | 11.1 | 
Arguments
- $name
- stringVariable name
- $default
- stringDefault value if the variable does not exist
- $hash
- stringWhere the var should come from (POST, GET, FILES, COOKIE, METHOD)
Response
stringRequested variable
getFloat
Fetches and returns a given filtered variable. The float filter only allows digits and periods. This is currently only a proxy function for getVar().
getFloat(string $name, string $default = 0.0, string $hash = 'default') : float
See getVar() for more in-depth documentation on the parameters.
| since | 11.1 | 
|---|---|
| deprecated | 12.1 | 
Arguments
- $name
- stringVariable name.
- $default
- stringDefault value if the variable does not exist.
- $hash
- stringWhere the var should come from (POST, GET, FILES, COOKIE, METHOD).
Response
floatRequested variable.
getInt
Fetches and returns a given filtered variable. The integer filter will allow only digits and the - sign to be returned. This is currently only a proxy function for getVar().
getInt(string $name, string $default, string $hash = 'default') : integer
See getVar() for more in-depth documentation on the parameters.
| since | 11.1 | 
|---|---|
| deprecated | 12.1 | 
Arguments
- $name
- stringVariable name.
- $default
- stringDefault value if the variable does not exist.
- $hash
- stringWhere the var should come from (POST, GET, FILES, COOKIE, METHOD).
Response
integerRequested variable.
getMethod
Gets the request method.
getMethod() : string
| since | 11.1 | 
|---|---|
| deprecated | 12.1 | 
Response
string
getString
Fetches and returns a given filtered variable. The string filter deletes 'bad' HTML code, if not overridden by the mask.
getString(string $name, string $default = '', string $hash = 'default', integer $mask) : string
This is currently only a proxy function for getVar().
See getVar() for more in-depth documentation on the parameters.
| since | 11.1 | 
|---|---|
| deprecated | 12.1 | 
Arguments
- $name
- stringVariable name
- $default
- stringDefault value if the variable does not exist
- $hash
- stringWhere the var should come from (POST, GET, FILES, COOKIE, METHOD)
- $mask
- integerFilter mask for the variable
Response
stringRequested variable
getUInt
Fetches and returns a given filtered variable. The unsigned integer filter will allow only digits to be returned. This is currently only a proxy function for getVar().
getUInt(string $name, string $default, string $hash = 'default') : integer
See getVar() for more in-depth documentation on the parameters.
| deprecated | 12.1 | 
|---|---|
| since | 11.1 | 
Arguments
- $name
- stringVariable name.
- $default
- stringDefault value if the variable does not exist.
- $hash
- stringWhere the var should come from (POST, GET, FILES, COOKIE, METHOD).
Response
integerRequested variable.
getURI
Gets the full request path.
getURI() : string
| since | 11.1 | 
|---|---|
| deprecated | 12.1 | 
Response
string
getVar
Fetches and returns a given variable.
getVar(string $name, string $default = null, string $hash = 'default', string $type = 'none', integer $mask) : mixed
The default behaviour is fetching variables depending on the current request method: GET and HEAD will result in returning an entry from $_GET, POST and PUT will result in returning an entry from $_POST.
You can force the source by setting the $hash parameter:
post $_POST get $_GET files $_FILES cookie $_COOKIE env $_ENV server $_SERVER method via current $_SERVER['REQUEST_METHOD'] default $_REQUEST
| since | 11.1 | 
|---|---|
| deprecated | 12.1 Use JInput::Get | 
Arguments
- $name
- stringVariable name.
- $default
- stringDefault value if the variable does not exist.
- $hash
- stringWhere the var should come from (POST, GET, FILES, COOKIE, METHOD).
- $type
- stringReturn type for the variable, for valid values see {@link JFilterInput::clean()}.
- $mask
- integerFilter mask for the variable.
Response
mixedRequested variable.
getWord
Fetches and returns a given filtered variable. The word filter only allows the characters [A-Za-z_]. This is currently only a proxy function for getVar().
getWord(string $name, string $default = '', string $hash = 'default') : string
See getVar() for more in-depth documentation on the parameters.
| since | 11.1 | 
|---|---|
| deprecated | 12.1 | 
Arguments
- $name
- stringVariable name.
- $default
- stringDefault value if the variable does not exist.
- $hash
- stringWhere the var should come from (POST, GET, FILES, COOKIE, METHOD).
Response
stringRequested variable.
set
Sets a request variable.
set(array $array, string $hash = 'default', boolean $overwrite = true) : void
| deprecated | 12.1 Use JInput::Set | 
|---|---|
| see | \JInput::Set | 
| since | 11.1 | 
Arguments
- $array
- arrayAn associative array of key-value pairs.
- $hash
- stringThe request variable to set (POST, GET, FILES, METHOD).
- $overwrite
- booleanIf true and an existing key is found, the value is overwritten, otherwise it is ignored.
setVar
Set a variable in one of the request variables.
setVar(string $name, string $value = null, string $hash = 'method', boolean $overwrite = true) : string
| since | 11.1 | 
|---|---|
| deprecated | 12.1 | 
Arguments
- $name
- stringName
- $value
- stringValue
- $hash
- stringHash
- $overwrite
- booleanBoolean
Response
stringPrevious value