Uri

Extends AbstractUri

Uri Class

This class parses a URI and provides a common interface for the Joomla Framework to access and manipulate a URI.

since

1.0

package

Joomla Framework

Methods

__construct

Constructor.

__construct( uri = null) : 
inherited

You can pass a URI string to the constructor to initialise a specific URI.

since

1.0

Arguments

uri

stringThe optional URI string

Response

mixed

__toString

Magic method to get the string representation of the UriInterface object.

__toString() : 
inherited
since

1.0

Response

string

buildQuery

Build a query from an array (reverse of the PHP parse_str()).

buildQuery(mixed||string|int params) : 
inherited static
see parse_str()
since

1.0

Arguments

params

array<string|int, mixed>The array of key => value pairs to return as a query string.

Response

stringThe resulting query string.

cleanPath

Resolves //, ../ and ./ from a path and returns the result.

cleanPath( path) : 
inherited

For example: /foo/bar/../boo.php => /foo/boo.php /foo/bar/../../boo.php => /boo.php /foo/bar/.././/boo.php => /foo/boo.php

since

1.0

Arguments

path

stringThe URI path to clean.

Response

stringCleaned and resolved URI path.

delVar

Removes an item from the query string variables if it exists

delVar( name) : 
since

1.0

Arguments

name

stringName of variable to remove.

Response

void

getFragment

Get the URI anchor string

getFragment() : 
inherited
since

1.0

Response

stringThe URI anchor string.

getHost

Get the URI host

getHost() : 
inherited
since

1.0

Response

stringThe hostname/IP or null if no hostname/IP was specified.

getPass

Get the URI password

getPass() : 
inherited
since

1.0

Response

stringThe password, or null if no password was specified.

getPath

Gets the URI path string

getPath() : 
inherited
since

1.0

Response

stringThe URI path string.

getPort

Get the URI port

getPort() : 
inherited
since

1.0

Response

intThe port number, or null if no port was specified.

getQuery

Returns flat query string.

getQuery( toArray = false) : string|array
inherited
since

1.0

Arguments

toArray

boolTrue to return the query as a key => value pair array.

Response

string|array<string|int, mixed>Query string or Array of parts in query string depending on the function param

getScheme

Get the URI scheme (protocol)

getScheme() : 
inherited
since

1.0

Response

stringThe URI scheme.

getUser

Get the URI username

getUser() : 
inherited
since

1.0

Response

stringThe username, or null if no username was specified.

getVar

Returns a query variable by name.

getVar( name,  default = null) : 
inherited
since

1.0

Arguments

name

stringName of the query variable to get.

default

stringDefault value to return if the variable is not set.

Response

mixedRequested query variable if present otherwise the default value.

hasVar

Checks if variable exists.

hasVar( name) : 
inherited
since

1.0

Arguments

name

stringName of the query variable to check.

Response

boolTrue if the variable exists.

isSsl

Checks whether the current URI is using HTTPS.

isSsl() : 
inherited
since

1.0

Response

boolTrue if using SSL via HTTPS.

parse

Parse a given URI and populate the class fields.

parse( uri) : 
inherited
since

1.0

Arguments

uri

stringThe URI string to parse.

Response

boolTrue on success.

render

Returns full uri string.

render( parts = self::ALL) : 
inherited
since

1.2.0

Arguments

parts

intA bitmask specifying the parts to render.

Response

stringThe rendered URI string.

setFragment

Set the URI anchor string

setFragment( anchor) : \Joomla\Uri\Uri
since

1.0

Arguments

anchor

stringThe URI anchor string.

Response

UriThis method supports chaining.

setHost

Set the URI host

setHost( host) : \Joomla\Uri\Uri
since

1.0

Arguments

host

stringThe URI host.

Response

UriThis method supports chaining.

setPass

Set the URI password

setPass( pass) : \Joomla\Uri\Uri
since

1.0

Arguments

pass

stringThe URI password.

Response

UriThis method supports chaining.

setPath

Set the URI path string

setPath( path) : \Joomla\Uri\Uri
since

1.0

Arguments

path

stringThe URI path string.

Response

UriThis method supports chaining.

setPort

Set the URI port

setPort( port) : \Joomla\Uri\Uri
since

1.0

Arguments

port

intThe URI port number.

Response

UriThis method supports chaining.

setQuery

Sets the query to a supplied string in format foo=bar&x=y

setQuery(array|string query) : 
since

1.0

Arguments

query

array<string|int, mixed>|stringThe query string or array.

Response

void

setScheme

Set the URI scheme (protocol)

setScheme( scheme) : \Joomla\Uri\Uri
since

1.0

Arguments

scheme

stringThe URI scheme.

Response

UriThis method supports chaining.

setUser

Set the URI username

setUser( user) : \Joomla\Uri\Uri
since

1.0

Arguments

user

stringThe URI username.

Response

UriThis method supports chaining.

setVar

Adds a query variable and value, replacing the value if it already exists and returning the old value

setVar( name,  value) : 
since

1.0

Arguments

name

stringName of the query variable to set.

value

stringValue of the query variable.

Response

stringPrevious value for the query variable.

toString

Returns full URI string.

toString(mixed||string|int parts = ['scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment']) : 
inherited
since

1.0

Arguments

parts

array<string|int, mixed>An array of strings specifying the parts to render.

Response

stringThe rendered URI string.

Properties

uri

Original URI

inherited
since

1.0

Type(s)

string

scheme

Protocol

inherited
since

1.0

Type(s)

string

host

Host

inherited
since

1.0

Type(s)

string

port

Port

inherited
since

1.0

Type(s)

int

user

Username

inherited
since

1.0

Type(s)

string

pass

Password

inherited
since

1.0

Type(s)

string

path

Path

inherited
since

1.0

Type(s)

string

query

Query

inherited
since

1.0

Type(s)

string|null

fragment

Anchor

inherited
since

1.0

Type(s)

string

vars

Query variable hash

inherited
since

1.0

Type(s)

array<string|int, mixed>