AnewtURL class

This class provides static methods for easy URL manipulation.

Class Overview

This class provides static methods for easy URL manipulation.

Public Static Methods

static build($path, $parameters=null) [static]

Build a URL from the passed parameters.

You can provide a single path string, or an array of strings, in which case each of the items in $path is a path component. The path components will be concatenated, separated by slashes.

All slashes are normalized. If the first path component has a leading slash, the resulting string will also have a leading slash and if it doesn't, the resulting string won't have one either. The same goes for the trailing slash: if the last path component ends with a slash, the resulting string will have one as well.

If $parameters is passed, a HTTP query string will be appended to the url using the this associatve array.

Example:

$url = AnewtURL::join(array('/path/to', $file), array('foo' => 'bar'));

Parameters

$path

Single string or array of strings (each item is a path component of the url)

$parameters

Associative array used to build a query string (optional)

Return value

The resulting URL path

See also

static parse($url) [static]

Parse a URL into a path and an array of query parameters.

This is (partly) the inverse operation of inverse AnewtURL::build() and can be used to parse an url into a path and query parameters (the GET string).

Parameters

$url

string The url to parse.

Return value

A (path, parameters) code containing a string and an associative array.

See also