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

Traits

Strict class for better experience.

Properties

static array $defaultPorts
string $scheme
string $user
string $password
string $host
int $port
string $path
string $query
string $fragment

Methods

__construct(string|Url|UrlImmutable $url = null)

No description

Url
setScheme(string $scheme)

No description

string
getScheme()

No description

Url
setUser(string $user)

No description

string
getUser()

No description

Url
setPassword(string $password)

No description

string
getPassword()

No description

Url
setHost(string $host)

No description

string
getHost()

No description

string
getDomain(int $level = 2)

Returns the part of domain.

Url
setPort(int $port)

No description

int|null
getPort()

No description

Url
setPath(string $path)

No description

string
getPath()

No description

Url
setQuery($query)

No description

Url
appendQuery($query)

No description

string
getQuery()

No description

array
getQueryParameters()

No description

mixed
getQueryParameter(string $name)

No description

Url
setQueryParameter(string $name, $value)

No description

Url
setFragment(string $fragment)

No description

string
getFragment()

No description

string
getAbsoluteUrl()

No description

string
getAuthority()

Returns the [user[:pass]@]host[:port] part of URI.

string
getHostUrl()

Returns the scheme and authority part of URI.

string
getBasePath() deprecated

No description

string
getBaseUrl() deprecated

No description

string
getRelativeUrl() deprecated

No description

bool
isEqual(string|Url $url)

URL comparison.

Url
canonicalize() deprecated

Transforms URL to canonical form.

string
__toString()

No description

string
jsonSerialize()

No description

array
export()

No description

static string
unescape(string $s, string $reserved = '%;/?:@&=+$,')

Similar to rawurldecode, but preserves reserved chars encoded.

static array
parseQuery(string $s)

Parses query string. Is affected by directive arg_separator.input.

Details

at line 84
__construct(string|Url|UrlImmutable $url = null)

Parameters

string|Url|UrlImmutable $url

Exceptions

InvalidArgumentException if URL is malformed

at line 111
Url setScheme(string $scheme)

Parameters

string $scheme

Return Value

Url

at line 118
string getScheme()

Return Value

string

at line 125
Url setUser(string $user)

Parameters

string $user

Return Value

Url

at line 132
string getUser()

Return Value

string

at line 139
Url setPassword(string $password)

Parameters

string $password

Return Value

Url

at line 146
string getPassword()

Return Value

string

at line 153
Url setHost(string $host)

Parameters

string $host

Return Value

Url

at line 161
string getHost()

Return Value

string

at line 170
string getDomain(int $level = 2)

Returns the part of domain.

Parameters

int $level

Return Value

string

at line 179
Url setPort(int $port)

Parameters

int $port

Return Value

Url

at line 186
int|null getPort()

Return Value

int|null

at line 193
Url setPath(string $path)

Parameters

string $path

Return Value

Url

at line 203
string getPath()

Return Value

string

at line 213
Url setQuery($query)

Parameters

$query

Return Value

Url

at line 224
Url appendQuery($query)

Parameters

$query

Return Value

Url

at line 233
string getQuery()

Return Value

string

at line 239
array getQueryParameters()

Return Value

array

at line 246
mixed getQueryParameter(string $name)

Parameters

string $name

Return Value

mixed

at line 259
Url setQueryParameter(string $name, $value)

Parameters

string $name
$value

Return Value

Url

at line 267
Url setFragment(string $fragment)

Parameters

string $fragment

Return Value

Url

at line 274
string getFragment()

Return Value

string

at line 280
string getAbsoluteUrl()

Return Value

string

at line 291
string getAuthority()

Returns the [user[:pass]@]host[:port] part of URI.

Return Value

string

at line 308
string getHostUrl()

Returns the scheme and authority part of URI.

Return Value

string

at line 316
string getBasePath() deprecated

deprecated

Return Value

string

at line 324
string getBaseUrl() deprecated

deprecated

Return Value

string

at line 331
string getRelativeUrl() deprecated

deprecated

Return Value

string

at line 341
bool isEqual(string|Url $url)

URL comparison.

Parameters

string|Url $url

Return Value

bool

at line 364
Url canonicalize() deprecated

deprecated

Transforms URL to canonical form.

Return Value

Url

at line 376
string __toString()

Return Value

string

at line 382
string jsonSerialize()

Return Value

string

at line 389
final array export()

Return Value

array

at line 398
static string unescape(string $s, string $reserved = '%;/?:@&=+$,')

Similar to rawurldecode, but preserves reserved chars encoded.

Parameters

string $s
string $reserved

Return Value

string

at line 417
static array parseQuery(string $s)

Parses query string. Is affected by directive arg_separator.input.

Parameters

string $s

Return Value

array