Url
class Url implements JsonSerializable
Mutable representation of a URL.
scheme user password host port path query fragment
| | | | | | | |
/--\ /--\ /------\ /-------\ /--\/------------\ /--------\ /------\
http://john:x0y17575@nette.org:8042/en/manual.php?name=param#fragment <-- absoluteUrl
\______\__________________________/
| |
hostUrl authority
Properties
| static array<string,int> | $defaultPorts | ||
| string | $scheme | ||
| string | $user | ||
| string | $password | ||
| string | $host | ||
| int | $port | ||
| string | $path | ||
| string | $query | ||
| string | $fragment | ||
| string read-only | $absoluteUrl | ||
| string read-only | $authority | ||
| string read-only | $hostUrl | ||
| string read-only | $basePath | ||
| string read-only | $baseUrl | ||
| string read-only | $relativeUrl | ||
| array<string,mixed> read-only | $queryParameters |
Methods
No description
No description
No description
Returns the specified number of rightmost domain labels (e.g. level 2 of 'www.nette.org' -> 'nette.org').
Returns the port number, falling back to the default port for the scheme if not explicitly set.
Returns the default port for the current scheme, or null if the scheme is not recognized.
No description
Merges query parameters into the existing query. Array values use union (existing keys are preserved); string values are appended and reparsed.
No description
No description
No description
No description
No description
No description
No description
Returns the [user[:pass]@]host[:port] part of URI.
Returns the scheme and authority part of URI.
Checks whether two URLs are equal, ignoring query parameter order and trailing dots in hostnames.
Normalizes the URL to canonical form: percent-encodes path, lowercases and trims the host, and converts IDN ASCII to Unicode.
No description
No description
No description
Decodes percent-encoded characters, but keeps reserved characters (specified in $reserved) encoded.
Parses query string. Is affected by directive arg_separator.input.
Checks whether the URL is absolute, i.e. starts with a scheme followed by a colon.
Resolves dot segments (. and ..) in a URL path, as per RFC 3986.
Details
at line 70
__construct(UrlImmutable|null $url = null)
No description
at line 93
Url
setScheme(string $scheme)
No description
at line 100
string
getScheme()
No description
at line 107
Url
setUser(string $user)
deprecated
deprecated
No description
at line 115
string
getUser()
deprecated
deprecated
No description
at line 122
Url
setPassword(string $password)
deprecated
deprecated
No description
at line 130
string
getPassword()
deprecated
deprecated
No description
at line 136
Url
setHost(string $host)
No description
at line 144
string
getHost()
No description
at line 154
string
getDomain(int $level = 2)
Returns the specified number of rightmost domain labels (e.g. level 2 of 'www.nette.org' -> 'nette.org').
Negative values trim from the right instead.
at line 166
Url
setPort(int $port)
No description
at line 176
int|null
getPort()
Returns the port number, falling back to the default port for the scheme if not explicitly set.
at line 185
int|null
getDefaultPort()
Returns the default port for the current scheme, or null if the scheme is not recognized.
at line 194
Url
setPath(string $path)
Sets the path. Automatically prepends a leading slash when a host is set.
at line 205
string
getPath()
No description
at line 212
Url
setQuery(string|array $query)
No description
at line 224
Url
appendQuery(string|array $query)
Merges query parameters into the existing query. Array values use union (existing keys are preserved); string values are appended and reparsed.
at line 233
string
getQuery()
No description
at line 240
array
getQueryParameters()
No description
at line 246
mixed
getQueryParameter(string $name)
No description
at line 252
Url
setQueryParameter(string $name, mixed $value)
No description
at line 259
Url
setFragment(string $fragment)
No description
at line 266
string
getFragment()
No description
at line 272
string
getAbsoluteUrl()
No description
at line 283
string
getAuthority()
Returns the [user[:pass]@]host[:port] part of URI.
at line 300
string
getHostUrl()
Returns the scheme and authority part of URI.
at line 308
string
getBasePath()
deprecated
deprecated
No description
at line 316
string
getBaseUrl()
deprecated
deprecated
No description
at line 323
string
getRelativeUrl()
deprecated
deprecated
No description
at line 332
bool
isEqual(UrlImmutable $url)
Checks whether two URLs are equal, ignoring query parameter order and trailing dots in hostnames.
at line 357
Url
canonicalize()
Normalizes the URL to canonical form: percent-encodes path, lowercases and trims the host, and converts IDN ASCII to Unicode.
at line 370
string
__toString()
No description
at line 376
string
jsonSerialize()
No description
at line 386
final array
export()
| internal |
No description
at line 413
static string
unescape(string $s, string $reserved = '%;/?:@&=+$,')
Decodes percent-encoded characters, but keeps reserved characters (specified in $reserved) encoded.
at line 434
static array
parseQuery(string $s)
Parses query string. Is affected by directive arg_separator.input.
at line 447
static bool
isAbsolute(string $url)
Checks whether the URL is absolute, i.e. starts with a scheme followed by a colon.
at line 456
static string
removeDotSegments(string $path)
Resolves dot segments (. and ..) in a URL path, as per RFC 3986.