Uri
Extends \Joomla\Uri\AbstractUriUri Class
This class parses a URI and provides a common interface for the Joomla Framework to access and manipulate a URI.
since |
1.0 |
---|
Methods
__construct
Constructor.
__construct(string $uri = null)
You can pass a URI string to the constructor to initialise a specific URI.
since |
1.0 |
---|
Arguments
- $uri
string
The optional URI string
__toString
Magic method to get the string representation of the URI object.
__toString() : string
since |
1.0 |
---|
Response
string
buildQuery
Build a query from an array (reverse of the PHP parse_str()).
buildQuery(array $params) : string
see | \Joomla\Uri\parse_str() |
---|---|
since |
1.0 |
Arguments
- $params
array
The array of key => value pairs to return as a query string.
Response
string
The resulting query string.
cleanPath
Resolves //, .
cleanPath(string $path) : string
./ and ./ from a path and returns the result. Eg:
/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
string
The URI path to clean.
Response
string
Cleaned and resolved URI path.
delVar
Removes an item from the query string variables if it exists.
delVar(string $name) : void
since |
1.0 |
---|
Arguments
- $name
string
Name of variable to remove.
getFragment
Get the URI anchor string Everything after the "#".
getFragment() : string
since |
1.0 |
---|
Response
string
The URI anchor string.
getHost
Get URI host Returns the hostname/ip or null if no hostname/ip was specified.
getHost() : string
since |
1.0 |
---|
Response
string
The URI host.
getPass
Get URI password Returns the password, or null if no password was specified.
getPass() : string
since |
1.0 |
---|
Response
string
The URI password.
getPath
Gets the URI path string.
getPath() : string
since |
1.0 |
---|
Response
string
The URI path string.
getPort
Get URI port Returns the port number, or null if no port was specified.
getPort() : integer
since |
1.0 |
---|
Response
integer
The URI port number.
getQuery
Returns flat query string.
getQuery(boolean $toArray = false) : string|array
since |
1.0 |
---|
Arguments
- $toArray
boolean
True to return the query as a key => value pair array.
Response
string|array
Query string or Array of parts in query string depending on the function param
getScheme
Get URI scheme (protocol) ie. http, https, ftp, etc.
getScheme() : string
..
since |
1.0 |
---|
Response
string
The URI scheme.
getUser
Get URI username Returns the username, or null if no username was specified.
getUser() : string
since |
1.0 |
---|
Response
string
The URI username.
getVar
Returns a query variable by name.
getVar(string $name, string $default = null) : mixed
since |
1.0 |
---|
Arguments
- $name
string
Name of the query variable to get.- $default
string
Default value to return if the variable is not set.
Response
mixed
Value of the specified query variable.
hasVar
Checks if variable exists.
hasVar(string $name) : boolean
since |
1.0 |
---|
Arguments
- $name
string
Name of the query variable to check.
Response
boolean
True if the variable exists.
isSsl
Checks whether the current URI is using HTTPS.
isSsl() : boolean
since |
1.0 |
---|
Response
boolean
True if using SSL via HTTPS.
parse
Parse a given URI and populate the class fields.
parse(string $uri) : boolean
since |
1.0 |
---|
Arguments
- $uri
string
The URI string to parse.
Response
boolean
True on success.
render
Returns full uri string.
render(integer $parts = self::ALL) : string
since |
1.2.0 |
---|
Arguments
- $parts
integer
A bitmask specifying the parts to render.
Response
string
The rendered URI string.
setFragment
Set the URI anchor string everything after the "#".
setFragment(string $anchor) : void
since |
1.0 |
---|
Arguments
- $anchor
string
The URI anchor string.
setHost
Set URI host.
setHost(string $host) : void
since |
1.0 |
---|
Arguments
- $host
string
The URI host.
setPass
Set URI password.
setPass(string $pass) : void
since |
1.0 |
---|
Arguments
- $pass
string
The URI password.
setPath
Set the URI path string.
setPath(string $path) : void
since |
1.0 |
---|
Arguments
- $path
string
The URI path string.
setPort
Set URI port.
setPort(integer $port) : void
since |
1.0 |
---|
Arguments
- $port
integer
The URI port number.
setQuery
Sets the query to a supplied string in format: foo=bar&x=y
setQuery(mixed $query) : void
since |
1.0 |
---|
Arguments
- $query
mixed
The query string or array.
setScheme
Set URI scheme (protocol) ie. http, https, ftp, etc.
setScheme(string $scheme) : void
..
since |
1.0 |
---|
Arguments
- $scheme
string
The URI scheme.
setUser
Set URI username.
setUser(string $user) : void
since |
1.0 |
---|
Arguments
- $user
string
The URI username.
setVar
Adds a query variable and value, replacing the value if it already exists and returning the old value.
setVar(string $name, string $value) : string
since |
1.0 |
---|
Arguments
- $name
string
Name of the query variable to set.- $value
string
Value of the query variable.
Response
string
Previous value for the query variable.
toString
Returns full uri string.
toString(array $parts = array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment')) : string
since |
1.0 |
---|
Arguments
- $parts
array
An array of strings specifying the parts to render.
Response
string
The rendered URI string.
Properties
uri
Original URI
since |
1.0 |
---|
Type(s)
string
scheme
Protocol
since |
1.0 |
---|
Type(s)
string
host
Host
since |
1.0 |
---|
Type(s)
string
port
Port
since |
1.0 |
---|
Type(s)
integer
user
Username
since |
1.0 |
---|
Type(s)
string
pass
Password
since |
1.0 |
---|
Type(s)
string
path
Path
since |
1.0 |
---|
Type(s)
string
query
Query
since |
1.0 |
---|
Type(s)
string
fragment
Anchor
since |
1.0 |
---|
Type(s)
string
vars
Query variable hash
since |
1.0 |
---|
Type(s)
array