$input API variable / WireInput class

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.

Show $var?             Show args?        

Common

NameReturnSummary 
$input->cookie()
null mixed WireInputDataRetrieve a named COOKIE variable value or all COOKIE variables
Can also be used as property: $input->cookie
 
$input->get()
null mixed WireInputDataRetrieve a named GET variable value, or all GET variables (from URL query string)
Can also be used as property: $input->get
 
$input->httpsUrl()
stringSame as httpUrl() method but always uses https scheme, rather than current request scheme 
$input->post()
null mixed WireInputDataRetrieve a named POST variable value, or all POST variables
Can also be used as property: $input->post
 
$input->requestMethod()
string boolReturn the current request method (i.e. GET, POST, etc.) or blank if not known 
$input->setLazy()
(nothing)Set for lazy loading 
$input->whitelist()
null mixed WireInputDataGet or set a whitelist variable
Can also be used as property: $input->whitelist
 

URL segments

NameReturnSummary 
$input->pageNum()
intReturn the current pagination/page number (starting from 1)
Can also be used as property: $input->pageNum
 
$input->pageNumStr()
stringReturn the string that represents the page number URL segment 
$input->setPageNum(int $num)
(nothing)Set the current page number. 
$input->setUrlSegment(int $num, $value)
(nothing)Set a URL segment value 
$input->urlSegment()
stringRetrieve the URL segment with the given index (starting from 1) 
$input->urlSegment1 string First URL segment  
$input->urlSegment2 string Second URL segment  
$input->urlSegment3 string Third URL segment, and so on...  
$input->urlSegmentStr()
stringGet the string of URL segments separated by slashes
Can also be used as property: $input->urlSegmentStr
 
$input->urlSegments()
arrayRetrieve array of all URL segments
Can also be used as property: $input->urlSegments
 

URLs

NameReturnSummary 
$input->httpHostUrl()
stringGet current scheme and URL for hostname without any path or query string 
$input->httpUrl()
stringGet the http URL that initiated the current request, including scheme, URL segments and page numbers
Can also be used as property: $input->httpUrl
 
$input->queryString()
stringReturn the unsanitized query string that was part of this request, or blank if none
Can also be used as property: $input->queryString
 
$input->scheme()
stringReturn the current access scheme/protocol
Can also be used as property: $input->scheme
 
$input->url()
stringGet 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.137

Twitter updates

  • ProcessWire 3.0.142 has a lot of updates but the biggest is the addition of custom fields support for file and image fields. In this post, we take a closer look at that, and also outline all of the new features in the just-released FormBuilder v40— More
    11 October 2019
  • This week’s dev branch version brings you improvements to ProcessWire’s input->cookie API variable, plus it adds the ability to modify system URLs and paths at runtime. This post also includes some examples to demonstrate just how useful this can be— More
    20 September 2019
  • New post: This week we’ll take a look at a new version of FormBuilder that's on the way (with a screencast), as well as the latest version of the core: ProcessWire 3.0.140— More
    6 September 2019

Latest news

  • ProcessWire Weekly #283
    The 283rd issue of ProcessWire Weekly introduces ProcessWire 3.0.142 and FormBuilder v40, highlights some conference content, and features a new weekly poll continuing with the #processwireworks theme. Read on!
    Weekly.pw / 12 October 2019
  • ProcessWire 3.0.142 core updates
    This latest version of the core on the dev branch has a lot of updates, bnd the biggest is the addition of custom fields support for file and image fields. In this post, we take a closer look and also outline all of the new features in the just-released FormBuilder v40.
    Blog / 11 October 2019
  • Subscribe to weekly ProcessWire news

“We were really happy to build our new portfolio website on ProcessWire! We wanted something that gave us plenty of control on the back-end, without any bloat on the front end - just a nice, easy to access API for all our content that left us free to design and build however we liked.” —Castus, web design agency in Sheffield, UK