class ParsedUri

A RFC3986 compliant URI parser

Constants

URI_REGEX

Methods

__construct(mixed $uri = null)

Constructor for creating a new parsed URI

boolean
isAbsolute()

Returns true if this is an absolute (complete) URI

boolean
isRelative()

Returns true if this is an relative (partial) URI

string
getScheme()

Returns the scheme of the URI (e.g. http)

setScheme(string $scheme)

Sets the scheme of the URI (e.g. http)

string
getAuthority()

Returns the authority of the URI (e.g. www.example.com:8080)

setAuthority(string $authority)

Sets the authority of the URI (e.g. www.example.com:8080)

string
getPath()

Returns the path of the URI (e.g. /foo/bar)

setPath(string $path)

Set the path of the URI (e.g. /foo/bar)

string
getQuery()

Returns the query string part of the URI (e.g. foo=bar)

setQuery(string $query)

Set the query string of the URI (e.g. foo=bar)

string
getFragment()

Returns the fragment part of the URI (i.e. after the #)

setFragment(string $fragment)

Set the fragment of the URI (i.e. after the #)

normalise()

Normalises the path of this URI if it has one.

resolve($relUri)

Resolves a relative URI using this URI as the base URI.

string
toString()

Convert the parsed URI back into a string

string
__toString()

Magic method to convert the URI, when casted, back to a string

Details

at line 69
__construct(mixed $uri = null)

Constructor for creating a new parsed URI

The $uri parameter can either be a string or an associative array with the following keys: scheme, authority, path, query, fragment

Parameters

mixed $uri The URI as a string or an array

at line 100
boolean isAbsolute()

Returns true if this is an absolute (complete) URI

Return Value

boolean

at line 108
boolean isRelative()

Returns true if this is an relative (partial) URI

Return Value

boolean

at line 116
string getScheme()

Returns the scheme of the URI (e.g. http)

Return Value

string

at line 124
setScheme(string $scheme)

Sets the scheme of the URI (e.g. http)

Parameters

string $scheme The new value for the scheme of the URI

at line 132
string getAuthority()

Returns the authority of the URI (e.g. www.example.com:8080)

Return Value

string

at line 140
setAuthority(string $authority)

Sets the authority of the URI (e.g. www.example.com:8080)

Parameters

string $authority The new value for the authority component of the URI

at line 148
string getPath()

Returns the path of the URI (e.g. /foo/bar)

Return Value

string

at line 156
setPath(string $path)

Set the path of the URI (e.g. /foo/bar)

Parameters

string $path The new value for the path component of the URI

at line 164
string getQuery()

Returns the query string part of the URI (e.g. foo=bar)

Return Value

string

at line 172
setQuery(string $query)

Set the query string of the URI (e.g. foo=bar)

Parameters

string $query The new value for the query string component of the URI

at line 180
string getFragment()

Returns the fragment part of the URI (i.e. after the #)

Return Value

string

at line 188
setFragment(string $fragment)

Set the fragment of the URI (i.e. after the #)

Parameters

string $fragment The new value for the fragment component of the URI

at line 202
ParsedUri normalise()

Normalises the path of this URI if it has one.

Normalising a path means that any unnecessary '.' and '..' segments are removed. For example, the URI http://example.com/a/b/../c/./d would be normalised to http://example.com/a/c/d

Return Value

ParsedUri

at line 254
resolve($relUri)

Resolves a relative URI using this URI as the base URI.

Parameters

$relUri

at line 313
string toString()

Convert the parsed URI back into a string

Return Value

string The URI as a string

at line 336
string __toString()

Magic method to convert the URI, when casted, back to a string

Return Value

string The URI as a string