webCOMAND

request::header()

Access an HTTP (and HTTPS) header based on the header name, such as 'Accept-Encoding'.  Headers are sent to a web page by the web browser with each request.

Prototype

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

Parameters

  • key - Name of the header to retrieve.  If NULL or no key is provided, an associative array of all headers 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 header exists, the value is returned as a string, including an empty string.  Otherwise, FALSE is returned.

Example

// retrieve the Accept-Encoding header
$request = new \io_comand_web\request();
$accept_encoding = $request->header('Accept-Encoding');