Documentation

Horde_Url
in package

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

Tags
author

Jan Schneider jan@horde.org

author

Michael Slusarz slusarz@horde.org

category

Horde

Table of Contents

$anchor  : string
The anchor string (a/k/a fragment).
$parameters  : array<string|int, mixed>
The query parameters.
$pathInfo  : string
Any PATH_INFO to be added to the URL.
$raw  : bool
Whether to output the URL in the raw URL format or HTML-encoded.
$toStringCallback  : callable
A callback function to use when converting to a string.
$url  : string
The basic URL, without query parameters.
$_cache  : array<string|int, mixed>
Cached parameter list for use in toString().
__construct()  : mixed
Constructor.
__toString()  : string
Creates the full URL string.
add()  : Horde_Url
Adds one or more query parameters.
copy()  : Horde_Url
Returns a clone of this object. Useful for chaining.
link()  : string
Generates a HTML link tag out of this URL.
redirect()  : mixed
Sends a redirect request to the browser to the URL in this object.
remove()  : Horde_Url
Removes one ore more parameters.
setAnchor()  : Horde_Url
Sets the URL anchor.
setRaw()  : Horde_Url
Sets the $raw value. This call can be chained.
setScheme()  : Horde_Url
Sets the URL scheme.
toString()  : string
Creates the full URL string.
unique()  : Horde_Url
Add a unique parameter to the URL to aid in cache-busting.
uriB64Decode()  : string
Decode URL-safe base64 data, dealing with missing '='.
uriB64Encode()  : string
URL-safe base64 encoding, with trimmed '='.
_getParameters()  : array<string|int, mixed>
Return a formatted list of URL parameters.

Properties

$anchor

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

public string $anchor = ''

$parameters

The query parameters.

public array<string|int, mixed> $parameters = array()

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

$pathInfo

Any PATH_INFO to be added to the URL.

public string $pathInfo

$raw

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

public bool $raw

$toStringCallback

A callback function to use when converting to a string.

public callable $toStringCallback

$url

The basic URL, without query parameters.

public string $url

$_cache

Cached parameter list for use in toString().

protected array<string|int, mixed> $_cache

Methods

__construct()

Constructor.

public __construct([string|Horde_Url $url = '' ][, bool $raw = null ]) : mixed
Parameters
$url : string|Horde_Url = ''

The basic URL, with or without query parameters.

$raw : bool = null

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

Return values
mixed

__toString()

Creates the full URL string.

public __toString() : string
Return values
string

The string representation of this object.

add()

Adds one or more query parameters.

public add(mixed $parameters[, string $value = null ]) : Horde_Url
Parameters
$parameters : mixed

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

$value : string = null

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

Return values
Horde_Url

This (modified) object, to allow chaining.

copy()

Returns a clone of this object. Useful for chaining.

public copy() : Horde_Url
Return values
Horde_Url

A clone of this object.

Generates a HTML link tag out of this URL.

public link([array<string|int, mixed> $attributes = array() ]) : string
Parameters
$attributes : array<string|int, mixed> = array()

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.

Return values
string

An tag representing this URL.

remove()

Removes one ore more parameters.

public remove(mixed $parameters) : Horde_Url
Parameters
$parameters : mixed
Return values
Horde_Url

This (modified) object, to allow chaining.

setAnchor()

Sets the URL anchor.

public setAnchor(string $anchor) : Horde_Url
Parameters
$anchor : string

An anchor to add.

Return values
Horde_Url

This (modified) object, to allow chaining.

setRaw()

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

public setRaw(bool $raw) : Horde_Url
Parameters
$raw : bool

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

Return values
Horde_Url

This object, to allow chaining.

setScheme()

Sets the URL scheme.

public setScheme([string $scheme = 'http' ][, bool $replace = false ]) : Horde_Url
Parameters
$scheme : string = 'http'

The URL scheme.

$replace : bool = false

Force using $scheme, even if it already exists?

Return values
Horde_Url

This object, to allow chaining.

toString()

Creates the full URL string.

public toString([bool $raw = false ][, bool $full = true ]) : string
Parameters
$raw : bool = false

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

$full : bool = true

Output the full URL?

Return values
string

The string representation of this object.

unique()

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

public unique() : Horde_Url
Return values
Horde_Url

This (modified) object, to allow chaining.

uriB64Decode()

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

public static uriB64Decode(string $string) : string
Parameters
$string : string

Encoded data.

Return values
string

Decoded data.

uriB64Encode()

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

public static uriB64Encode(string $string) : string
Parameters
$string : string

String to encode.

Return values
string

URL-safe, base64 encoded data.

_getParameters()

Return a formatted list of URL parameters.

protected _getParameters() : array<string|int, mixed>
Return values
array<string|int, mixed>

Parameter list.

Search results