Url
in package
Contains utility methods for handling URL strings.
The methods in this class are able to deal with URLs.
Tags
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
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
Return values
array<string|int, string> —An array with the host and the path of the URL.