Overview

Namespaces

  • esperecyan
    • url
      • lib

Classes

  • HostProcessing
  • Infrastructure
  • PercentEncoding
  • Terminology
  • URL
  • URLencoding
  • Overview
  • Namespace
  • Class
  • Tree

Class URL

A universal identifier (a URL record). A URL consists of components, namely a scheme, scheme data, username, password, host, port, path, query, and fragment.

Namespace: esperecyan\url\lib
Link: URL Standard
Located at lib\URL.php
Methods summary
public string
# __get( string $name )

Parameters

$name

Returns

string
public
# __set( string $name, boolean $value )

Parameters

$name
$value
public boolean
# isSpecial( )

A URL is special if its scheme is a special scheme.

A URL is special if its scheme is a special scheme.

Returns

boolean
Return true if a URL is special.

Link

URL Standard
public boolean
# isLocal( )

A URL is local if its scheme is a local scheme.

A URL is local if its scheme is a local scheme.

Deprecated

5.0.0 The term “URL is local” has been moved from the URL Standard specification to the Fetch Standard specification.


Returns

boolean
Return true if a URL is local.

Link

Editorial: move some terminology to the Fetch Standard · whatwg/url@8fb8684
URL Standard
public boolean
# isIncludingCredentials( )

A URL includes credentials if either its username is not the empty string or its password is non-null.

A URL includes credentials if either its username is not the empty string or its password is non-null.

Returns

boolean
Return true if a URL includes credentials.

Link

URL Standard
public boolean
# cannotHaveUsernamePasswordPort( )

A URL cannot have a username/password/port if its host is null or the empty string, its cannot-be-a-base-URL flag is set, or its scheme is “file”.

A URL cannot have a username/password/port if its host is null or the empty string, its cannot-be-a-base-URL flag is set, or its scheme is “file”.

Returns

boolean
Return true if a URL cannot have a username/password/port.

Link

URL Standard
public static boolean
# stringStartsWithWindowsDriveLetter( string $str )

Returns true if the specified string “starts with a Windows drive letter”.

Returns true if the specified string “starts with a Windows drive letter”.

Parameters

$str
A UTF-8 string.

Returns

boolean

Link

URL Standard
public
# shortenPath( )

Shortens a path.

Shortens a path.

Link

URL Standard
public
# popPath( )

Alias of shortenPath().

Alias of shortenPath().

Deprecated

5.0.0 The method has been renamed to shortenPath.

See

\esperecyan\url\lib\URL::shortenPath()

Link

Editorial: pop → shorten · whatwg/url@c94f6f2
public static esperecyan\url\lib\URL|false
# parseURL( string $input, esperecyan\url\lib\URL $base = null, string|null $encodingOverride = null )

The URL parser.

The URL parser.

Parameters

$input
A UTF-8 string.
$base
A base URL.
$encodingOverride
A valid name of an encoding.

Returns

esperecyan\url\lib\URL|false

Link

URL Standard
public static esperecyan\url\lib\URL|false|
# parseBasicURL( string $input, esperecyan\url\lib\URL $base = null, string|null $encodingOverride = null, array $urlAndStateOverride = null )

The basic URL parser.

The basic URL parser.

Parameters

$input
A UTF-8 string.
$base
A base URL.
$encodingOverride
A valid name of an encoding.
$urlAndStateOverride
An URL (“url” key) and a state override (“state override” key).

Returns

esperecyan\url\lib\URL|false|

Throws

DomainException
If $urlAndStateOverride['state override'] is invalid.

Link

URL Standard
public
# setUsername( string $username )

Sets the username of the URL given $username.

Sets the username of the URL given $username.

Parameters

$username
A UTF-8 string.

Link

URL Standard
public
# setPassword( string $password )

Sets the password of the URL given $password.

Sets the password of the URL given $password.

Parameters

$password
A UTF-8 string.

Link

URL Standard
public
# serializeURL( boolean $excludeFragmentFlag = false )

The URL serializer.

The URL serializer.

Parameters

$excludeFragmentFlag
An exclude fragment flag.

Link

URL Standard
public (string|integer|null)[]|string
# getOrigin( )

A URL’s origin is the origin, switching on URL’s scheme.

A URL’s origin is the origin, switching on URL’s scheme.

Returns

(string|integer|null)[]|string

An array with the first element the scheme, the second element the host, the third element the port, and the four element the domain. Or an unique string of 23 characters.

Link

URL Standard
Constants summary
string WINDOWS_DRIVE_LETTER

The regular expression (PCRE) pattern matching a Windows drive letter.

The regular expression (PCRE) pattern matching a Windows drive letter.

Link

URL Standard
# '/^[a-z][:|]$/ui'
string NORMALIZED_WINDOWS_DRIVE_LETTER

The regular expression (PCRE) pattern matching a normalized Windows drive letter.

The regular expression (PCRE) pattern matching a normalized Windows drive letter.

Link

URL Standard
# '/^[a-z]:$/ui'
string SINGLE_DOT_PATH_SEGMENT

The regular expression (PCRE) pattern matching a single-dot path segment.

The regular expression (PCRE) pattern matching a single-dot path segment.

Link

URL Standard
# '/^(?:\\.|%2e)$/ui'
string DOUBLE_DOT_PATH_SEGMENT

The regular expression (PCRE) pattern matching a double-dot path segment.

The regular expression (PCRE) pattern matching a double-dot path segment.

Link

URL Standard
# '/^(?:\\.|%2e){2}$/ui'
string URL_CODE_POINTS

The regular expression (PCRE) pattern matching the URL code points.

The regular expression (PCRE) pattern matching the URL code points.

Link

URL Standard
# '/[!$&\'()*+,\\-.\\/:;=?@_~\xC2\xA0-퟿-﷏ﷰ-�𐀀-🿽𠀀-𯿽𰀀-𿿽񀀀-񏿽񐀀-񟿽񠀀-񯿽񰀀-񿿽򀀀-򏿽򐀀-򟿽򠀀-򯿽򰀀-򿿽󀀀-󏿽󐀀-󟿽󠀀-󯿽󰀀-󿿽􀀀-􏿽]/u'
Properties summary
public string $scheme

A URL’s scheme is a string that identifies the type of URL and can be used to dispatch a URL for further processing after parsing.

A URL’s scheme is a string that identifies the type of URL and can be used to dispatch a URL for further processing after parsing.

Link

URL Standard
# ''
public string $username

A URL’s username is a string identifying a user.

A URL’s username is a string identifying a user.

Link

URL Standard
# ''
public string $password

A URL’s password is either null or a string identifying a user’s credentials.

A URL’s password is either null or a string identifying a user’s credentials.

Link

URL Standard
# ''
public string|integer|float|integer[]|null $host

A URL’s host is either null or a host.

A URL’s host is either null or a host.

Link

URL Standard
# null
public integer|null $port

A URL’s port is either null or a 16-bit integer that identifies a networking port.

A URL’s port is either null or a 16-bit integer that identifies a networking port.

Link

URL Standard
# null
public string[] $path

A URL’s path is a list of zero or more strings holding data, usually identifying a location in hierarchical form.

A URL’s path is a list of zero or more strings holding data, usually identifying a location in hierarchical form.

Link

URL Standard
# []
public string|null $query

A URL’s query is either null or a string holding data.

A URL’s query is either null or a string holding data.

Link

URL Standard
# null
public string $fragment

A URL’s fragment is either null or a string holding data that can be used for further processing on the resource the URL’s other components identify.

A URL’s fragment is either null or a string holding data that can be used for further processing on the resource the URL’s other components identify.

Link

URL Standard
# null
public A $cannotBeABaseURLFlag

URL also has an associated cannot-be-a-base-URL flag.

URL also has an associated cannot-be-a-base-URL flag.

Link

URL Standard
# false
public object|null $object

A URL also has an associated object that is either null or a Blob object.

A URL also has an associated object that is either null or a Blob object.

Link

URL Standard
# null
public static (int|null)[] $specialSchemes

A special scheme is a scheme in the key of this array. A default port is a special scheme’s optional corresponding port and is in the value on the key.

A special scheme is a scheme in the key of this array. A default port is a special scheme’s optional corresponding port and is in the value on the key.

Link

URL Standard
# [ 'ftp' => 21, 'file' => null, 'gopher' => 70, 'http' => 80, 'https' => 443, 'ws' => 80, 'wss' => 443, ]
public static string[] $localSchemes

A local scheme is a scheme that is one of “about”, “blob”, “data”, and “filesystem”.

A local scheme is a scheme that is one of “about”, “blob”, “data”, and “filesystem”.

Deprecated

5.0.0 The term “local scheme” has been moved from the URL Standard specification to the Fetch Standard specification.


Link

Editorial: move some terminology to the Fetch Standard · whatwg/url@8fb8684
URL Standard
# ['about', 'blob', 'data', 'filesystem']
Magic properties summary
public boolean $nonRelativeFlag

[Deprecated] Alias of $cannotBeABaseURLFlag.

esperecyan/url documentation API documentation generated by ApiGen