Topics

Class Request

Get current HTTP request information

Namespace: Ip

Methods:

__construct( )
setPost( mixed $post )

Set post variables

Parameters:

mixed $post
setServer( mixed $server )

Set server data

Parameters:

mixed $server
setQuery( mixed $query )

Set GET query

Parameters:

mixed $query
setRequest( mixed $request )

Set request data

Parameters:

mixed $request
boolean isGet( )

Check if HTTP request data is provided using GET method

Return values:

boolean Returns true for GET method
boolean isPost( )

Check if HTTP request data is provided using POST method

Return values:

boolean Returns true for POST method
mustBePost( )

Require to provide HTTP request data using POST method

Throws:

Ip\Exception is thrown if POST method was not used.
boolean isHttps( )

Check if HTTPS protocol is used

Return values:

boolean Returns true for HTTPS request
string getMethod( )

Get request method, such as 'GET', 'HEAD', 'POST', or 'PUT'

Return values:

string Request method
mixed getQuery( [ string $name = null ] , [ mixed $default = null ] )

Return GET query parameter if $name is passed. Returns all query parameters if name == null.

Parameters:

string $name query parameter name
mixed $default default value if no GET parameter exists

Return values:

mixed GET query variable (all query variables if $name == null)
mixed getPost( [ string $name = null ] , [ mixed $default = null ] )

Returns POST parameter if $name is passed. Returns all query parameters if name == null.

Parameters:

string $name query parameter name
mixed $default default value if no GET parameter exists

Return values:

mixed GET query variable (all query variables if $name == null)
mixed getRequest( [ string $name = null ] , [ mixed $default = null ] )

Return request parameter if $name is passed. Returns all request parameters if $name == null.

Parameters:

string $name query parameter name
mixed $default default value if no GET parameter exists

Return values:

mixed GET query variable (all query variables if $name == null)
mixed getServer( [ string $name = null ] , [ string $default = null ] )

Return parameters, such as headers, paths, and script locations, provided in $_SERVER array

Parameters:

string $name parameter name
string $default default value returned when a server parameter is null

Return values:

mixed
string getUrl( )

Get current page URL

Return values:

string URL address
string getRelativePath( )

Gets relative path from base URL

Return values:

string Path after BASE_URL
comments powered by Disqus