Methods |
public
static
|
getMethod(): string
Gets the request method
|
#
|
public
static
|
getVar(string $name, mixed $default = null, string $hash = 'default', string $type = 'none', int $mask = 0): mixed
Fetches and returns a given variable.
Fetches and returns a given variable.
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
Parameters
$name |
Variable name
|
$default |
Default value if the variable does not exist
|
$hash |
Source of variable value (POST, GET, FILES, COOKIE, METHOD)
|
$type |
Return type for the variable (INT, FLOAT, BOOLEAN, WORD,
ALPHANUM, CMD, BASE64, STRING, ARRAY, PATH, NONE) For more
information see FilterInput::clean().
|
$mask |
Filter mask for the variable
|
Returns
|
#
|
public
static
|
getInt(string $name, int $default = 0, string $hash = 'default'): int
Fetches and returns a given filtered variable. The integer
filter will allow only digits to be returned. This is…
Fetches and returns a given filtered variable. The integer
filter will allow only digits to be returned. This is currently
only a proxy function for getVar().
See getVar() for more in-depth documentation on the parameters.
Parameters
$name |
Variable name
|
$default |
Default value if the variable does not exist
|
$hash |
Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
|
Returns
|
#
|
public
static
|
getFloat(string $name, float $default = 0.0, string $hash = 'default'): float
Fetches and returns a given filtered variable. The float
filter only allows digits and periods. This is currently…
Fetches and returns a given filtered variable. The float
filter only allows digits and periods. This is currently
only a proxy function for getVar().
See getVar() for more in-depth documentation on the parameters.
Parameters
$name |
Variable name
|
$default |
Default value if the variable does not exist
|
$hash |
Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
|
Returns
|
#
|
public
static
|
getBool(string $name, bool $default = false, string $hash = 'default'): bool
Fetches and returns a given filtered variable. The bool
filter will only return true/false bool values. This is…
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().
See getVar() for more in-depth documentation on the parameters.
Parameters
$name |
Variable name
|
$default |
Default value if the variable does not exist
|
$hash |
Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
|
Returns
|
#
|
public
static
|
getWord(string $name, string $default = '', string $hash = 'default'): string
Fetches and returns a given filtered variable. The word
filter only allows the characters [A-Za-z_]. This is currently…
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().
See getVar() for more in-depth documentation on the parameters.
Parameters
$name |
Variable name
|
$default |
Default value if the variable does not exist
|
$hash |
Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
|
Returns
|
#
|
public
static
|
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.-_] and returns in…
Fetches and returns a given filtered variable. The cmd filter only allows the characters
[A-Za-z0-9.-_] and returns in lower case. This is currently a proxy function for getVar().
See getVar() for more in-depth documentation on the parameters.
Parameters
$name |
Variable name
|
$default |
Default value if the variable does not exist
|
$hash |
Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
|
Returns
|
#
|
public
static
|
getString(string $name, string $default = '', string $hash = 'default', int $mask = 0): string
Fetches and returns a given filtered variable. The string
filter deletes 'bad' HTML code, if not overridden by the mask…
Fetches and returns a given filtered variable. The string
filter deletes 'bad' HTML code, if not overridden by the mask.
This is currently only a proxy function for getVar().
See getVar() for more in-depth documentation on the parameters.
Parameters
$name |
Variable name
|
$default |
Default value if the variable does not exist
|
$hash |
Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
|
$mask |
Filter mask for the variable
|
Returns
|
#
|
public
static
|
getArray(string $name, mixed $default = [], string $hash = 'default'): array
Fetches and returns an array
Fetches and returns an array
Parameters
$name |
Variable name
|
$default |
Default value if the variable does not exist
|
$hash |
Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
|
|
#
|
public
static
|
getText(string $name, string $default = '', string $hash = 'default'): string
Fetches and returns raw text
Fetches and returns raw text
Parameters
$name |
Variable name
|
$default |
Default value if the variable does not exist
|
$hash |
Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
|
Returns
|
#
|
public
static
|
getUrl(string $name, string $default = '', string $hash = 'default'): string
Fetches and returns a web url
Fetches and returns a web url
Parameters
$name |
Variable name
|
$default |
Default value if the variable does not exist
|
$hash |
Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
|
Returns
|
#
|
public
static
|
getPath(string $name, string $default = '', string $hash = 'default'): string
Fetches and returns a file (or web) path
Fetches and returns a file (or web) path
Parameters
$name |
Variable name
|
$default |
Default value if the variable does not exist
|
$hash |
Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
|
Returns
|
#
|
public
static
|
getEmail(string $name, string $default = '', string $hash = 'default'): string
Fetches and returns an email address
Fetches and returns an email address
Parameters
$name |
Variable name
|
$default |
Default value if the variable does not exist
|
$hash |
Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
|
Returns
email address or default if invalid
|
#
|
public
static
|
getIP(string $name, string $default = '', string $hash = 'default'): string
Fetches and returns an IP address
Fetches and returns an IP address
Parameters
$name |
Variable name
|
$default |
Default value if the variable does not exist
|
$hash |
Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
|
Returns
IP address or default if invalid
|
#
|
public
static
|
getHeader(string $headerName, string|null $default = ''): string
get request header
Parameters
$headerName |
name of header to retrieve, case-insensitive
|
$default |
default to return if named header is not found
|
Returns
header value or default if header was not found
|
#
|
public
static
|
hasVar(string $name, string $hash = 'default'): bool
See if a variable exists in one of the request hashes
See if a variable exists in one of the request hashes
Parameters
$name |
variable to look for
|
$hash |
hash to check
|
Returns
True if hash has an element 'name', otherwise false
|
#
|
public
static
|
setVar(string $name, string $value = null, string $hash = 'method', bool $overwrite = true): string
Set a variable in one of the request variables
Set a variable in one of the request variables
Parameters
$name |
Name
|
$value |
Value
|
$hash |
Hash
|
$overwrite |
Boolean
|
Returns
|
#
|
public
static
|
get(string $hash = 'default', int $mask = 0): mixed
Fetches and returns a request array.
Fetches and returns a request array.
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
Parameters
$hash |
to get (POST, GET, FILES, METHOD)
|
$mask |
Filter mask for the variable
|
Returns
|
#
|
public
static
|
set(array $array, string $hash = 'method', bool $overwrite = true): void
Sets a request variable
Parameters
$array |
An associative array of key-value pairs
|
$hash |
The request variable to set (POST, GET, FILES, METHOD)
|
$overwrite |
If true and an existing key is found, the value is overwritten,
otherwise it is ignored
|
|
#
|
protected
static
|
cleanVar(mixed $var, int $mask = 0, string $type = null): string
Clean up an input variable.
Clean up an input variable.
Parameters
$var |
The input variable.
|
$mask |
Filter 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 |
The variable type. See {@link FilterInput::clean()}.
|
|
#
|
protected
static
|
cleanVars(mixed $var, int $mask = 0, string $type = null): string
Clean up an array of variables.
Clean up an array of variables.
Parameters
$var |
The input variable.
|
$mask |
Filter bit mask. See {@link Request::cleanVar()}
|
$type |
The variable type. See {@link FilterInput::clean()}.
|
|
#
|
protected
static
|
stripSlashesRecursive(string|array $value): array
Strips slashes recursively on an array
Strips slashes recursively on an array
Parameters
$value |
string of Array of (nested arrays of) strings
|
Returns
The input array with stripslashes applied to it
|
#
|