Documentation

UriUtil
in package

FinalYes

Table of Contents

Constants

URI_DEFAULT_PORTS  = ['http' => 80, 'https' => 443, 'ftp' => 21, 'gopher' => 70, 'nntp' => 119, 'news' => 119, 'telnet' => 23, 'tn3270' => 23, 'imap' => 143, 'pop' => 110, 'ldap' => 389]

Methods

isAbsolute()  : bool
Checks Whether the URI is absolute, i.e. it has a scheme.
isAbsolutePathReference()  : bool
Checks Whether the URI is an absolute-path reference.
isDefaultPort()  : bool
Checks whether the UriInterface has a port set and if that port is one of the default ports for the given scheme
isNetworkPathReference()  : bool
Checks Whether the URI is a network-path reference.
isRelativePathReference()  : bool
Checks Whether the URI is a relative-path reference.
parseUrl()  : array{scheme?: string, host?: int|string, port?: string, user?: string, pass?: string, path?: string, query?: string, fragment?: string}|null
UTF-8 aware \parse_url() replacement.
withoutQueryValue()  : UriInterface
Removes a specific query string value.
withQueryValue()  : UriInterface
Adds a specific query string value.

Constants

URI_DEFAULT_PORTS

public mixed URI_DEFAULT_PORTS = ['http' => 80, 'https' => 443, 'ftp' => 21, 'gopher' => 70, 'nntp' => 119, 'news' => 119, 'telnet' => 23, 'tn3270' => 23, 'imap' => 143, 'pop' => 110, 'ldap' => 389]

Methods

isAbsolute()

Checks Whether the URI is absolute, i.e. it has a scheme.

public static isAbsolute(UriInterface $uri) : bool

An instance of UriInterface can either be an absolute URI or a relative reference. This method returns true if it is the former. An absolute URI has a scheme. A relative reference is used to express a URI relative to another URI, the base URI. Relative references can be divided into several forms:

  • network-path references, e.g. '//example.com/path'
  • absolute-path references, e.g. '/path'
  • relative-path references, e.g. 'subpath'
Parameters
$uri : UriInterface
Tags
see
self::isNetworkPathReference
see
self::isAbsolutePathReference
see
self::isRelativePathReference
see
https://tools.ietf.org/html/rfc3986#section-4
Return values
bool

isAbsolutePathReference()

Checks Whether the URI is an absolute-path reference.

public static isAbsolutePathReference(UriInterface $uri) : bool

A relative reference that begins with a single slash character is termed an absolute-path reference.

Parameters
$uri : UriInterface
Tags
link
https://tools.ietf.org/html/rfc3986#section-4.2
Return values
bool

isDefaultPort()

Checks whether the UriInterface has a port set and if that port is one of the default ports for the given scheme

public static isDefaultPort(UriInterface $uri) : bool
Parameters
$uri : UriInterface
Return values
bool

isNetworkPathReference()

Checks Whether the URI is a network-path reference.

public static isNetworkPathReference(UriInterface $uri) : bool

A relative reference that begins with two slash characters is termed a network-path reference.

Parameters
$uri : UriInterface
Tags
link
https://tools.ietf.org/html/rfc3986#section-4.2
Return values
bool

isRelativePathReference()

Checks Whether the URI is a relative-path reference.

public static isRelativePathReference(UriInterface $uri) : bool

A relative reference that does not begin with a slash character is termed a relative-path reference.

Parameters
$uri : UriInterface
Tags
link
https://tools.ietf.org/html/rfc3986#section-4.2
Return values
bool

parseUrl()

UTF-8 aware \parse_url() replacement.

public static parseUrl(string $url) : array{scheme?: string, host?: int|string, port?: string, user?: string, pass?: string, path?: string, query?: string, fragment?: string}|null

The internal function produces broken output for non ASCII domain names (IDN) when used with locales other than "C".

On the other hand, cURL understands IDN correctly only when UTF-8 locale is configured ("C.UTF-8", "en_US.UTF-8", etc.).

Parameters
$url : string
Tags
see
https://bugs.php.net/bug.php?id=52923
see
https://www.php.net/manual/en/function.parse-url.php#114817
see
https://curl.haxx.se/libcurl/c/CURLOPT_URL.html#ENCODING
link
https://github.com/guzzle/psr7/blob/c0dcda9f54d145bd4d062a6d15f54931a67732f9/src/Uri.php#L89-L130
Return values
array{scheme?: string, host?: int|string, port?: string, user?: string, pass?: string, path?: string, query?: string, fragment?: string}|null

withoutQueryValue()

Removes a specific query string value.

public static withoutQueryValue(UriInterface $uri, string $key) : UriInterface

Any existing query string values that exactly match the provided $key are removed.

Parameters
$uri : UriInterface
$key : string
Return values
UriInterface

withQueryValue()

Adds a specific query string value.

public static withQueryValue(UriInterface $uri, string $key[, string|null $value = null ]) : UriInterface

Any existing query string values that exactly match the provided $key are removed and replaced with the given $key $value pair.

A value of null will set the query string key without a value, e.g. "key" instead of "key=value".

Parameters
$uri : UriInterface
$key : string
$value : string|null = null
Return values
UriInterface

        
On this page

Search results