Uri Class
The Uri class allows you to interact with the URI.
create($uri = null, $variables = array(), $get_variables = array())
The create method allows you to create a URL with the given URI, including the base URL.
Static |
Yes |
Parameters |
Param |
Default |
Description |
$uri |
null
|
The URL. |
$variables |
array()
|
The variables for the URL. |
$get_variables |
array()
|
The query string additions to the URL, its values & keys can use variables from
the $variables array. |
|
Returns |
string |
Example |
echo Uri::create('controller/method');
// returns http://localhost/controller/method
echo Uri::create('controller/:some', array('some' => 'thing', 'and' => 'more'), array('what' => ':and'));
// returns http://localhost/controller/thing?what=more
|
current()
The current method allows you to fetch the current URL, including the base URL inside HMVC pattern.
Static |
Yes |
Parameters |
None |
Returns |
string |
Example |
// Example URL: http://localhost/module/controller/method
echo Uri::current(); // returns http://localhost/module/controller/method
|
detect()
The detect method detects the current URI to build the correct string.
Static |
Yes |
Parameters |
None |
Returns |
string |
Example |
// Example URL: http://localhost/controller/method
echo Uri::detect(); // returns controller/method
|
main()
The main method allows you to fetch the current URL, including the base URL.
Static |
Yes |
Parameters |
None |
Returns |
string |
Example |
// Example URL: http://localhost/controller/method
echo Uri::main(); // returns http://localhost/controller/method
|
segment($segment, $default = null)
The segment method allows you to return the desired segment, or false if it does not exist.
Static |
Yes |
Parameters |
Param |
Default |
Description |
$segment |
Required |
The segment number. |
$default |
null
|
The default? |
|
Returns |
string |
Example |
// Example URL: http://localhost/controller/method/param1/param2
echo Uri::segment(3); // returns param1
|
segments()
The segments method allows you to fetch the current URI segments in an array.
Static |
Yes |
Parameters |
None |
Returns |
array |
Example |
// Example URL: http://localhost/controller/method
echo Uri::segments(); // returns array(0 => 'controller', 1 => 'method')
|
string()
The string method allows you to fetch the current URI.
Static |
Yes |
Parameters |
None |
Returns |
string |
Example |
// Example URL: http://localhost/controller/method
echo Uri::string(); // returns controller/method
|