webCOMAND

request::request()

The request method provides access to HTTP (and HTTPS) GET and POST parameters.  POST parameters take precedence if a GET and POST parameter with the same name is provided.  See get() and post() methods for more information.

Prototype

string request(string $key = NULL, boolean $xss_filter = FALSE)

Parameters

  • key - Name of the parameter to retrieve.  If NULL or no key is provided, an associative array of all parameters will be returned.
  • xss_filter - Optional parameter to enable the cross site scripting filter when available, which converts potentially malicious HTML tags into HTML entities.

Return

If the GET or POST parameter exists, the value is returned as a string, including an empty string.  Otherwise, FALSE is returned.  POST parameters take precedence if a GET and POST parameter with the same name is provided.

Example

The following HTML form will POST a "search" parameter with the value "test".

<html>
<body>
    <h1>Search</h1>
    <form method="POST" action="?form=123">
        <input name="search" type="text" value="test" />
        <input type="submit" />
    </form>
</body>
</html>

The following PHP code will retrieve the posted search value.

// retrieve the value of the "form" GET parameter
// and "search" POST parameter
$request = new \io_comand_web\request();
$form = $request->request('form');
$search = $request->request('search');