Input
extends Input
in package
Input class.
This class extends framework's Input class and the framework's Input class available since v1.1.3.
Tags
Table of Contents
Properties
- $Container : Container
Methods
- __construct() : mixed
- Class constructor.
- cookie() : mixed
- Get cookie value.
- delete() : mixed
- Get input via DELETE method.
- filterRegexp() : mixed
- Filter data with regular expression.
- get() : mixed
- Get input via GET method.
- isNonHtmlAccept() : bool
- Check if HTTP accept type is non-HTML.
- isXhr() : bool
- Check if request/input is XHR (XMLHttpRequest) or Ajax.
- patch() : mixed
- Get input via PATCH method.
- post() : mixed
- Get input via POST method.
- put() : mixed
- Get input via PUT method.
- request() : mixed
- Get input via GET, POST, COOKIE.
- server() : mixed
- Get `$_SERVER` variable data.
- session() : mixed
- Get session value.
- filter() : mixed
- Filter data for inputs.
- inputParams() : mixed
- Get input parameters such as $_GET, $_POST, etc.
Properties
$Container
protected
Container
$Container
Methods
__construct()
Class constructor.
public
__construct([Container $Container = null ]) : mixed
Parameters
- $Container : Container = null
-
The DI container class. Only required for some method.
cookie()
Get cookie value.
public
cookie(string $name[, mixed $default = '' ][, int $filter = FILTER_UNSAFE_RAW ][, mixed $options = null ]) : mixed
To use this method correctly, the class constructor must contain the Container
and Config
class in it.
For the $filter
and $options
argument, please read more details at http://php.net/manual/en/function.filter-var.php page.
Parameters
- $name : string
-
The input name (cookie name) without suffix. The suffix will be automatically added.
- $default : mixed = ''
-
Default value to return if the input name is not exists.
- $filter : int = FILTER_UNSAFE_RAW
-
The ID of the filter to apply. See types of filters at http://php.net/manual/en/filter.filters.php page.
- $options : mixed = null
-
Associative array of options or bitwise disjunction of flags.
Return values
mixed —Return filtered input value.
delete()
Get input via DELETE method.
public
delete(string $name[, mixed $default = '' ][, int $filter = FILTER_UNSAFE_RAW ][, mixed $options = null ]) : mixed
For the $filter
and $options
argument, please read more details at http://php.net/manual/en/function.filter-var.php page.
Parameters
- $name : string
-
The input name.
- $default : mixed = ''
-
Default value to return if the input name is not exists.
- $filter : int = FILTER_UNSAFE_RAW
-
The ID of the filter to apply. See types of filters at http://php.net/manual/en/filter.filters.php page.
- $options : mixed = null
-
Associative array of options or bitwise disjunction of flags.
Return values
mixed —Return filtered input value.
filterRegexp()
Filter data with regular expression.
public
filterRegexp(mixed $variable[, mixed $pattern = '/([^wx{0080}-x{10FFFF} ~!@#$%^&*()+`-=[]\\{}|;:,./?]+)/u' ][, mixed $replacement = '' ]) : mixed
No more use anywhere. Use something else like RdbaString->filterSanitizeString()
instead.
Parameters
- $variable : mixed
-
The string or an array with strings to search and replace.
- $pattern : mixed = '/([^wx{0080}-x{10FFFF} ~!@#$%^&*()+`-=[]\\{}|;:,./?]+)/u'
-
The pattern to search for. It can be either a string or an array with strings. The default pattern is match English, numbers, Unicode, and followed characters.
- $replacement : mixed = ''
-
The string or an array with strings to replace. The default replacement is empty string.
Tags
Return values
mixed —Returns an array if the subject parameter is an array, or a string otherwise.
get()
Get input via GET method.
public
get(string $name[, mixed $default = '' ][, int $filter = FILTER_UNSAFE_RAW ][, mixed $options = null ]) : mixed
For the $filter
and $options
argument, please read more details at http://php.net/manual/en/function.filter-var.php page.
Parameters
- $name : string
-
The input name.
- $default : mixed = ''
-
Default value to return if the input name is not exists.
- $filter : int = FILTER_UNSAFE_RAW
-
The ID of the filter to apply. See types of filters at http://php.net/manual/en/filter.filters.php page.
- $options : mixed = null
-
Associative array of options or bitwise disjunction of flags.
Return values
mixed —Return filtered input value.
isNonHtmlAccept()
Check if HTTP accept type is non-HTML.
public
isNonHtmlAccept() : bool
For check HTTP accept that can be called via REST API (that is not contain XMLHttpRequest).
Return values
bool —Return true
if it is non-HTML accept type, false
for HTML or XHTML accept type.
isXhr()
Check if request/input is XHR (XMLHttpRequest) or Ajax.
public
isXhr() : bool
Return values
bool —Return true
if yes, false
if not.
patch()
Get input via PATCH method.
public
patch(string $name[, mixed $default = '' ][, int $filter = FILTER_UNSAFE_RAW ][, mixed $options = null ]) : mixed
For the $filter
and $options
argument, please read more details at http://php.net/manual/en/function.filter-var.php page.
Parameters
- $name : string
-
The input name.
- $default : mixed = ''
-
Default value to return if the input name is not exists.
- $filter : int = FILTER_UNSAFE_RAW
-
The ID of the filter to apply. See types of filters at http://php.net/manual/en/filter.filters.php page.
- $options : mixed = null
-
Associative array of options or bitwise disjunction of flags.
Return values
mixed —Return filtered input value.
post()
Get input via POST method.
public
post(string $name[, mixed $default = '' ][, int $filter = FILTER_UNSAFE_RAW ][, mixed $options = null ]) : mixed
For the $filter
and $options
argument, please read more details at http://php.net/manual/en/function.filter-var.php page.
Parameters
- $name : string
-
The input name.
- $default : mixed = ''
-
Default value to return if the input name is not exists.
- $filter : int = FILTER_UNSAFE_RAW
-
The ID of the filter to apply. See types of filters at http://php.net/manual/en/filter.filters.php page.
- $options : mixed = null
-
Associative array of options or bitwise disjunction of flags.
Return values
mixed —Return filtered input value.
put()
Get input via PUT method.
public
put(string $name[, mixed $default = '' ][, int $filter = FILTER_UNSAFE_RAW ][, mixed $options = null ]) : mixed
For the $filter
and $options
argument, please read more details at http://php.net/manual/en/function.filter-var.php page.
Parameters
- $name : string
-
The input name.
- $default : mixed = ''
-
Default value to return if the input name is not exists.
- $filter : int = FILTER_UNSAFE_RAW
-
The ID of the filter to apply. See types of filters at http://php.net/manual/en/filter.filters.php page.
- $options : mixed = null
-
Associative array of options or bitwise disjunction of flags.
Return values
mixed —Return filtered input value.
request()
Get input via GET, POST, COOKIE.
public
request(string $name[, mixed $default = '' ][, int $filter = FILTER_UNSAFE_RAW ][, mixed $options = null ]) : mixed
For the $filter
and $options
argument, please read more details at http://php.net/manual/en/function.filter-var.php page.
Parameters
- $name : string
-
The input name.
- $default : mixed = ''
-
Default value to return if the input name is not exists.
- $filter : int = FILTER_UNSAFE_RAW
-
The ID of the filter to apply. See types of filters at http://php.net/manual/en/filter.filters.php page.
- $options : mixed = null
-
Associative array of options or bitwise disjunction of flags.
Return values
mixed —Return filtered input value.
server()
Get `$_SERVER` variable data.
public
server(string $name[, mixed $default = '' ][, int $filter = FILTER_UNSAFE_RAW ][, mixed $options = null ]) : mixed
For the $filter
and $options
argument, please read more details at http://php.net/manual/en/function.filter-var.php page.
Parameters
- $name : string
-
The input name.
- $default : mixed = ''
-
Default value to return if the input name is not exists.
- $filter : int = FILTER_UNSAFE_RAW
-
The ID of the filter to apply. See types of filters at http://php.net/manual/en/filter.filters.php page.
- $options : mixed = null
-
Associative array of options or bitwise disjunction of flags.
Return values
mixed —Return filtered input value.
session()
Get session value.
public
session(string $name[, mixed $default = '' ][, int $filter = FILTER_UNSAFE_RAW ][, mixed $options = null ]) : mixed
For the $filter
and $options
argument, please read more details at http://php.net/manual/en/function.filter-var.php page.
Parameters
- $name : string
-
The input name.
- $default : mixed = ''
-
Default value to return if the input name is not exists.
- $filter : int = FILTER_UNSAFE_RAW
-
The ID of the filter to apply. See types of filters at http://php.net/manual/en/filter.filters.php page.
- $options : mixed = null
-
Associative array of options or bitwise disjunction of flags.
Return values
mixed —Return filtered input value.
filter()
Filter data for inputs.
protected
filter(mixed $variable[, int $filter = FILTER_UNSAFE_RAW ][, mixed $options = null ]) : mixed
Parameters
- $variable : mixed
-
Value to filter.
- $filter : int = FILTER_UNSAFE_RAW
-
The ID of the filter to apply. See types of filters at http://php.net/manual/en/filter.filters.php page.
- $options : mixed = null
-
Associative array of options or bitwise disjunction of flags.
Tags
Return values
mixed —Returns the filtered data, or false if the filter fails.
inputParams()
Get input parameters such as $_GET, $_POST, etc.
protected
inputParams(string $inputType, string $name[, mixed $default = '' ][, mixed $filter = FILTER_UNSAFE_RAW ][, mixed $options = null ]) : mixed
For the $filter
and $options
argument, please read more details at http://php.net/manual/en/function.filter-var.php page.
Parameters
- $inputType : string
-
The input type. For example: 'GET' will access input data from
$_GET
, 'POST' will access from$_POST
. - $name : string
-
The input name.
- $default : mixed = ''
-
Default value to return if the input name is not exists.
- $filter : mixed = FILTER_UNSAFE_RAW
-
The ID of the filter to apply. See types of filters at http://php.net/manual/en/filter.filters.php page.
- $options : mixed = null
-
Associative array of options or bitwise disjunction of flags.
Return values
mixed —Return filtered input value.