Provides a means to get user input from URLs, GET, POST, and COOKIE variables and more.
Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the WireInput
class also inherits all the methods and properties of: Wire.
Common
Name | Return | Summary | |
---|---|---|---|
$input->cookie() $input->cookie() $input->cookie(string $key = '', $valid = null, $fallback = null) | null mixed WireInputData | Retrieve a named COOKIE variable value or all COOKIE variables Can also be used as property: $input->cookie | |
$input->get() $input->get() $input->get(string $key = '', $valid = null, $fallback = null) | null mixed WireInputData | Retrieve a named GET variable value, or all GET variables (from URL query string) Can also be used as property: $input->get | |
$input->is() $input->is(string $method) $input->is(string $method) | bool | Is the current request of the specified type? | |
$input->post() $input->post() $input->post(string $key = '', $valid = null, $fallback = null) | null mixed WireInputData | Retrieve a named POST variable value, or all POST variables Can also be used as property: $input->post | |
$input->requestMethod() $input->requestMethod() $input->requestMethod(string $method = '') | string bool | Return the current request method (i.e. GET, POST, etc.) or blank if not known | |
$input->whitelist() $input->whitelist() $input->whitelist(string $key = '', mixed $value = null) | null mixed WireInputData | Get or set a whitelist variable Can also be used as property: $input->whitelist |
URL segments
Name | Return | Summary | |
---|---|---|---|
$input->pageNum() $input->pageNum() $input->pageNum() | int | Return the current pagination/page number (starting from 1) Can also be used as property: $input->pageNum | |
$input->pageNumStr() $input->pageNumStr() $input->pageNumStr(int $pageNum = 0) | string | Return the string that represents the page number URL segment | |
$input->setPageNum() $input->setPageNum(int $num) $input->setPageNum(int $num) | (nothing) | Set the current page number. | |
$input->setUrlSegment() $input->setUrlSegment(int $num, $value) $input->setUrlSegment(int $num, $value) | (nothing) | Set a URL segment value | |
$input->urlSegment() $input->urlSegment() $input->urlSegment($get = 1) | string int | Retrieve matching URL segment number or pattern | |
$input->urlSegment1() $input->urlSegment1() $input->urlSegment1($get = '') | string int bool | Same as urlSegment() method but apply only to 1st URL segment. (since 3.0.155) Can also be used as property: $input->urlSegment1 | |
$input->urlSegment2() $input->urlSegment2() $input->urlSegment2($get = '') | string int bool | Same as urlSegment() method but apply only to 2nd URL segment. (since 3.0.155) Can also be used as property: $input->urlSegment2 | |
$input->urlSegment3() $input->urlSegment3() $input->urlSegment3($get = '') | string int bool | Same as urlSegment() method but apply only to 3rd URL segment. (since 3.0.155) Can also be used as property: $input->urlSegment3 | |
$input->urlSegmentFirst() $input->urlSegmentFirst() $input->urlSegmentFirst($get = '') | string int bool | Same as urlSegment() method but apply only to first URL segment. (since 3.0.155) Can also be used as property: $input->urlSegmentFirst | |
$input->urlSegmentLast() $input->urlSegmentLast() $input->urlSegmentLast($get = '') | string int bool | Same as urlSegment() method but apply only to last URL segment. (since 3.0.155) Can also be used as property: $input->urlSegmentLast | |
$input->urlSegmentStr() $input->urlSegmentStr() $input->urlSegmentStr($verbose = false, array $options = []) | string | Get the string of URL segments separated by slashes Can also be used as property: $input->urlSegmentStr | |
$input->urlSegments() $input->urlSegments() $input->urlSegments() | array | Retrieve array of all URL segments Can also be used as property: $input->urlSegments |
URLs
Name | Return | Summary | |
---|---|---|---|
$input->canonicalUrl() $input->canonicalUrl() $input->canonicalUrl(array $options = []) | string | Generate canonical URL for current page and request | |
$input->httpHostUrl() $input->httpHostUrl() $input->httpHostUrl($scheme = null, string $httpHost = '') | string | Get current scheme and URL for hostname without any path or query string | |
$input->httpUrl() $input->httpUrl() $input->httpUrl($options = []) | string | Get the http URL that initiated the current request, including scheme, URL segments and page numbers Can also be used as property: $input->httpUrl | |
$input->httpsUrl() $input->httpsUrl() $input->httpsUrl($options = []) | string | Same as httpUrl() method but always uses https scheme, rather than current request scheme | |
$input->queryString() $input->queryString() $input->queryString(array $overrides = []) | string | Return the unsanitized query string that was part of this request, or blank if none Can also be used as property: $input->queryString | |
$input->queryStringClean() $input->queryStringClean() $input->queryStringClean(array $options = []) | string | Return a cleaned query string that was part of this request, or blank if none | |
$input->scheme() $input->scheme() $input->scheme() | string | Return the current access scheme/protocol Can also be used as property: $input->scheme | |
$input->url() $input->url() $input->url($options = []) | string | Get the URL that initiated the current request, including URL segments and page numbers Can also be used as property: $input->url |
Additional methods and properties
In addition to the methods and properties above, WireInput also inherits the methods and properties of these classes:
API reference based on ProcessWire core version 3.0.236