Documentation

Url
in package

Contains utility methods for handling URL strings.

The methods in this class are able to deal with URLs.

Tags
since
2.3
author

Bernhard Schussek bschussek@gmail.com

author

Claudio Zizza claudio@budgegeria.de

Table of Contents

makeRelative()  : string
Turns a URL into a relative path.
split()  : array<string|int, string>
Splits a URL into its host and the path.

Methods

makeRelative()

Turns a URL into a relative path.

public static makeRelative(string $url, string $baseUrl) : string

The result is a canonical path. This class is using functionality of Path class.

Parameters
$url : string

A URL to make relative.

$baseUrl : string

A base URL.

Tags
see
Path
throws
InvalidArgumentException

If the URL and base URL does not match.

Return values
string

split()

Splits a URL into its host and the path.

private static split(string $url) : array<string|int, string>
list ($root, $path) = Path::split("http://example.com/webmozart")
// => array("http://example.com", "/webmozart")

list ($root, $path) = Path::split("http://example.com")
// => array("http://example.com", "")
Parameters
$url : string

The URL to split.

Tags
throws
InvalidArgumentException

If $url is not a URL.

Return values
array<string|int, string>

An array with the host and the path of the URL.

Search results