webCOMAND

request::get()

The get method provides access to HTTP (and HTTPS) GET query parameters.  GET parameters are made available to a web page through the URL requested.  For example, a GET parameter key "search" can be passed the value "test" with the URL http://www.example.com/script.php?search=test

Prototype

string get(string $key = NULL, array $options = [])

Parameters

  • key - Name of the parameter to retrieve.  If NULL or no key is provided, an associative array of all parameters will be returned.
  • options - Array of options with the following key/value pairs.
    • default - A value to use if the request does not include the query parameter.

Return

If the GET parameter exists, the value is returned as a string, including an empty string.  Otherwise, FALSE is returned.

Example

// retrieve the value of the "search" GET parameter from a URL like
// http://www.example.com/script.php?search=test
$request = new \io_comand_web\request();
$search = $request->get('search', ['default' => '']);