\Horde_Url

The Horde_Url class represents a single URL and provides methods for manipulating URLs.

Summary

Methods
Properties
Constants
__construct()
copy()
add()
remove()
setAnchor()
setRaw()
setScheme()
toString()
__toString()
link()
unique()
redirect()
uriB64Encode()
uriB64Decode()
$anchor
$pathInfo
$parameters
$raw
$toStringCallback
$url
No constants found
_getParameters()
$_cache
N/A
No private methods found
No private properties found
N/A

Properties

$anchor

$anchor : string

The anchor string (a/k/a fragment).

Type

string

$pathInfo

$pathInfo : string

Any PATH_INFO to be added to the URL.

Type

string

$parameters

$parameters : array

The query parameters.

The keys are paramter names, the values parameter values. Array values will be added to the URL using name[]=value notation.

Type

array

$raw

$raw : boolean

Whether to output the URL in the raw URL format or HTML-encoded.

Type

boolean

$toStringCallback

$toStringCallback : callback

A callback function to use when converting to a string.

Type

callback

$url

$url : string

The basic URL, without query parameters.

Type

string

$_cache

$_cache : array

Cached parameter list for use in toString().

Type

array

Methods

__construct()

__construct(string|\Horde_Url  $url = '', boolean  $raw = null) 

Constructor.

Parameters

string|\Horde_Url $url

The basic URL, with or without query parameters.

boolean $raw

Whether to output the URL in the raw URL format or HTML-encoded.

copy()

copy() : \Horde_Url

Returns a clone of this object. Useful for chaining.

Returns

\Horde_Url

A clone of this object.

add()

add(mixed  $parameters, string  $value = null) : \Horde_Url

Adds one or more query parameters.

Parameters

mixed $parameters

Either the name value or an array of name/value pairs.

string $value

If specified, the value part ($parameters is then assumed to just be the parameter name).

Returns

\Horde_Url

This (modified) object, to allow chaining.

remove()

remove(  $parameters) : \Horde_Url

Removes one ore more parameters.

Parameters

$parameters

Returns

\Horde_Url

This (modified) object, to allow chaining.

setAnchor()

setAnchor(string  $anchor) : \Horde_Url

Sets the URL anchor.

Parameters

string $anchor

An anchor to add.

Returns

\Horde_Url

This (modified) object, to allow chaining.

setRaw()

setRaw(boolean  $raw) : \Horde_Url

Sets the $raw value. This call can be chained.

Parameters

boolean $raw

Whether to output the URL in the raw URL format or HTML-encoded.

Returns

\Horde_Url

This object, to allow chaining.

setScheme()

setScheme(string  $scheme = 'http', boolean  $replace = false) : \Horde_Url

Sets the URL scheme.

Parameters

string $scheme

The URL scheme.

boolean $replace

Force using $scheme, even if it already exists?

Returns

\Horde_Url

This object, to allow chaining.

toString()

toString(boolean  $raw = false, boolean  $full = true) : string

Creates the full URL string.

Parameters

boolean $raw

Whether to output the URL in the raw URL format or HTML-encoded.

boolean $full

Output the full URL?

Returns

string —

The string representation of this object.

__toString()

__toString() : string

Creates the full URL string.

Returns

string —

The string representation of this object.

link()

link(array  $attributes = array()) : string

Generates a HTML link tag out of this URL.

Parameters

array $attributes

A hash with any additional attributes to be added to the link. If the attribute name is suffixed with ".raw", the attribute value won't be HTML-encoded.

Returns

string —

An tag representing this URL.

unique()

unique() : \Horde_Url

Add a unique parameter to the URL to aid in cache-busting.

Returns

\Horde_Url

This (modified) object, to allow chaining.

redirect()

redirect() 

Sends a redirect request to the browser to the URL in this object.

Throws

\Horde_Url_Exception

uriB64Encode()

uriB64Encode(string  $string) : string

URL-safe base64 encoding, with trimmed '='.

Parameters

string $string

String to encode.

Returns

string —

URL-safe, base64 encoded data.

uriB64Decode()

uriB64Decode(string  $string) : string

Decode URL-safe base64 data, dealing with missing '='.

Parameters

string $string

Encoded data.

Returns

string —

Decoded data.

_getParameters()

_getParameters() : array

Return a formatted list of URL parameters.

Returns

array —

Parameter list.