AnewtRequest class

The AnewtRequest class contains request information.

Class Overview

The AnewtRequest class contains request information.

This class provides several static methods that can be used to get information about the current HTTP request.

URL methods

These method can be used to find out various forms of the request url, e.g. relative and absolute urls, domain names, and so on.

static url($include_query_string=true) [static]

Alias for AnewtRequest::relative_url().

Parameters

$include_query_string

Whether the query string (the part after the question mark in HTTP GET request should be included (optional, defaults to true)

Return value

The relative URL for the current request.

See also

static relative_url($include_query_string=true) [static]

Returns the relative URL for the current request.

Parameters

$include_query_string

Whether the query string (the part after the question mark in HTTP GET request should be included (optional, defaults to true)

Return value

The relative URL for the current request.

See also

static canonical_url($include_query_string=true) [static]

Returns the canonical URL for the current request.

This includes the http part, the hostname and (optionally) port number.

Parameters

$include_query_string

Whether the query string (the part after the question mark in HTTP GET request should be included (optional, defaults to true)

Return value

The canonical URL for the current request.

See also

static canonical_base_url() [static]

Returns the canonical base URL for the current request.

This includes the http part, the hostname and (optionally) port number.

Return value

The canonical base URL for the current request.

See also

static host() [static]

Returns the hostname as provided in the server configuration.

Return value

Host name for the current request.

static http_host() [static]

Returns the host name as provided in the client's HTTP Host header.

Note that this value should be treated as unsafe, since it's user-provided.

Return value

Host name for the current request.

static domain() [static]

Return the domain name for the current request.

Heuristics are used to detect the the domain name. This will fail horribly for extremely short domain names. A domain name is assumed to be the rightmost part of the full hostname. A test on very short strings is used to detect top level domains such as .com, .nl and double ones like .co.uk. This obviously fails for longer top level domains and extremely short domain names.

Return value

Domain name for the current request.

static referer() [static]

Return the HTTP referer of the current request, if any.

This method uses the HTTP_REFERER header in the HTTP request, and will return null if no referer was set.

Return value

The refererring url of the current request, or null.

GET, POST, and cookie methods

These methods allow you to find out the request method of the current request, and offers various type-safe methods to extract values from GET and POST parameters and cookies.

static method() [static]

Returns the method type of this request (GET or POST).

Return value

A string telling which type of request this is. This can be either 'GET' or 'POST'.

See also

static is_get() [static]

Check if the request is a HTTP GET request.

Return value

True if the request is a GET request, false otherwise.

See also

static is_post() [static]

Check if the request is a HTTP POST request.

Return value

True if the request is a POST request, false otherwise.

See also

static get_int($key, $default=null) [static]

Get an integer from the GET request data.

Parameters

$key

The name of the integer.

$default

The default value to return if no valid integer was found. If you omit this parameter, null is used.

Return value

A valid integer or the default value.

static post_int($key, $default=null) [static]

Gets an integer from the POST request data.

Parameters

$key

The name of the integer.

$default

The default value to return if no valid integer was found. If you omit this parameter, null is used.

Return value

A valid integer or the default value.

static get_string($key, $default=null) [static]

Gets a string from the GET request data.

Parameters

$key

The name of the string.

$default

The default value to return if no string was found. If you omit this parameter, null is used.

Return value

A string or the default value.

static post_string($key, $default=null) [static]

Gets a string from the POST request data.

Parameters

$key

The name of the string.

$default

The default value to return if no string was found. If you omit this parameter, null is used.

Return value

A string or the default value.

static get_bool($key, $default=null) [static]

Gets a boolean value from the GET data.

Parameters

$key

The name of the boolean.

$default

The default value to return if no valid boolean was found. If you omit this parameter, null is used.

Return value

A string or the default value.

See also

static post_bool($key, $default=null) [static]

Gets a boolean value from the POST data.

Parameters

$key

The name of the boolean.

$default

The default value to return if no valid boolean was found. If you omit this parameter, null is used.

Return value

A string or the default value.

See also