Uri Class

package Fuel
category Core
author Dan Horrigan
link http://docs.fuelphp.com/classes/uri.html

 Methods

Construct takes a URI or detects it if none is given and generates the segments.

__construct(string $uri) 

Parameters

$uri

string

The URI

Returns the URI string

__toString() : string

Returns

string

Gets the base URL, including the index_file if wanted.

base(bool $include_index) : string

Parameters

$include_index

bool

Whether to include index.php in the URL

Returns

string

Builds a query string by merging all array and string values passed.

build_query_string() : string

If a string is passed, it will be assumed to be a switch, and converted to "string=1".

Returns

string

Creates a url with the given uri, including the base url

create(string $uri, array $variables, array $get_variables, bool $secure) : string

Parameters

$uri

string

The uri to create the URL for

$variables

array

Some variables for the URL

$get_variables

array

Any GET urls to append via a query string

$secure

bool

If false, force http. If true, force https

Returns

string

Gets the current URL, including the BASE_URL

current() : string

Returns

string

Returns the full URI string

get() : string

Returns

stringThe URI string

Get the specified URI segment, return default if it doesn't exist.

get_segment(string $segment, mixed $default) : mixed

Segment index is 1 based, not 0 based

Parameters

$segment

string

The 1-based segment index

$default

mixed

The default value

Returns

mixed

Returns all of the URI segments

get_segments() : array

Returns

arrayThe URI segments

Gets the main request's URI

main() : string

Returns

string

Returns the desired segment, or $default if it does not exist.

segment(int $segment, mixed $default) : string

Parameters

$segment

int

The segment number (1-based index)

$default

mixed

Default value to return

Returns

string

Replace all * wildcards in a URI by the current segment in that location

segment_replace(string $url, bool $secure) : string

Parameters

$url

string

The url containing the wildcards

$secure

bool

To force a particular HTTP scheme

Returns

string

Returns all segments in an array

segments() : array

Returns

array

Returns the full uri as a string

string() : string

Returns

string

Converts the current URI segments to an associative array.

to_assoc(int $start) : array

If the URI has an odd number of segments, an empty value will be added.

Parameters

$start

int

segment number to start from. default value is the first segment

Returns

arraythe assoc array

Updates the query string of the current or passed URL with the data passed

update_query_string(array | string $vars, string | mixed $uri, bool $secure) : string

Parameters

$vars

arraystring

Assoc array of GET variables, or a get variable name

$uri

stringmixed

Optional URI to use if $vars is an array, otherwise the get variable name

$secure

bool

If false, force http. If true, force https

Returns

string

 Properties

 

<p>The URI segments</p>

$segments : array

 

<p>The URI string</p>

$uri : string