class Url implements JsonSerializable

URI Syntax (RFC 3986).

scheme  user  password  host  port  basePath   relativeUrl
  |      |      |        |      |    |             |
/--\   /--\ /------\ /-------\ /--\/--\/----------------------------\
http://john:x0y17575@nette.org:8042/en/manual.php?name=param#fragment  <-- absoluteUrl
       \__________________________/\____________/^\________/^\______/
                    |                     |           |         |
                authority               path        query    fragment

Properties

static array $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 read-only $queryParameters

Methods

__construct($url = null)

No description

Url
setScheme($value)

Sets the scheme part of URI.

string
getScheme()

Returns the scheme part of URI.

Url
setUser($value)

Sets the user name part of URI.

string
getUser()

Returns the user name part of URI.

Url
setPassword($value)

Sets the password part of URI.

string
getPassword()

Returns the password part of URI.

Url
setHost($value)

Sets the host part of URI.

string
getHost()

Returns the host part of URI.

string
getDomain($level = 2)

Returns the part of domain.

Url
setPort($value)

Sets the port part of URI.

int|null
getPort()

Returns the port part of URI.

Url
setPath($value)

Sets the path part of URI.

string
getPath()

Returns the path part of URI.

Url
setQuery($value)

Sets the query part of URI.

Url
appendQuery($value)

Appends the query part of URI.

string
getQuery()

Returns the query part of URI.

array
getQueryParameters()

No description

mixed
getQueryParameter($name, $default = null)

No description

Url
setQueryParameter($name, $value)

No description

Url
setFragment($value)

Sets the fragment part of URI.

string
getFragment()

Returns the fragment part of URI.

string
getAbsoluteUrl()

Returns the entire URI including query string and fragment.

string
getAuthority()

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

string
getHostUrl()

Returns the scheme and authority part of URI.

string
getBasePath()

Returns the base-path.

string
getBaseUrl()

Returns the base-URI.

string
getRelativeUrl()

Returns the relative-URI.

bool
isEqual($url)

URL comparison.

Url
canonicalize()

Transforms URL to canonical form.

string
__toString()

No description

string
jsonSerialize()

No description

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

Similar to rawurldecode, but preserves reserved chars encoded.

static array
parseQuery($s)

Parses query string.

Details

at line 90
__construct($url = null)

No description

Parameters

$url

Exceptions

InvalidArgumentException

at line 120
Url setScheme($value)

Sets the scheme part of URI.

Parameters

$value

Return Value

Url

at line 131
string getScheme()

Returns the scheme part of URI.

Return Value

string

at line 142
Url setUser($value)

Sets the user name part of URI.

Parameters

$value

Return Value

Url

at line 153
string getUser()

Returns the user name part of URI.

Return Value

string

at line 164
Url setPassword($value)

Sets the password part of URI.

Parameters

$value

Return Value

Url

at line 175
string getPassword()

Returns the password part of URI.

Return Value

string

at line 186
Url setHost($value)

Sets the host part of URI.

Parameters

$value

Return Value

Url

at line 198
string getHost()

Returns the host part of URI.

Return Value

string

at line 208
string getDomain($level = 2)

Returns the part of domain.

Parameters

$level

Return Value

string

at line 221
Url setPort($value)

Sets the port part of URI.

Parameters

$value

Return Value

Url

at line 232
int|null getPort()

Returns the port part of URI.

Return Value

int|null

at line 243
Url setPath($value)

Sets the path part of URI.

Parameters

$value

Return Value

Url

at line 257
string getPath()

Returns the path part of URI.

Return Value

string

at line 268
Url setQuery($value)

Sets the query part of URI.

Parameters

$value

Return Value

Url

at line 280
Url appendQuery($value)

Appends the query part of URI.

Parameters

$value

Return Value

Url

at line 293
string getQuery()

Returns the query part of URI.

Return Value

string

at line 302
array getQueryParameters()

No description

Return Value

array

at line 313
mixed getQueryParameter($name, $default = null)

No description

Parameters

$name
$default

Return Value

mixed

at line 324
Url setQueryParameter($name, $value)

No description

Parameters

$name
$value

Return Value

Url

at line 336
Url setFragment($value)

Sets the fragment part of URI.

Parameters

$value

Return Value

Url

at line 347
string getFragment()

Returns the fragment part of URI.

Return Value

string

at line 357
string getAbsoluteUrl()

Returns the entire URI including query string and fragment.

Return Value

string

at line 369
string getAuthority()

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

Return Value

string

at line 387
string getHostUrl()

Returns the scheme and authority part of URI.

Return Value

string

at line 398
string getBasePath()

Returns the base-path.

Return Value

string

at line 409
string getBaseUrl()

Returns the base-URI.

Return Value

string

at line 419
string getRelativeUrl()

Returns the relative-URI.

Return Value

string

at line 430
bool isEqual($url)

URL comparison.

Parameters

$url

Return Value

bool

at line 453
Url canonicalize()

Transforms URL to canonical form.

Return Value

Url

at line 468
string __toString()

No description

Return Value

string

at line 477
string jsonSerialize()

No description

Return Value

string

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

Similar to rawurldecode, but preserves reserved chars encoded.

Parameters

$s
$reserved

Return Value

string

at line 509
static array parseQuery($s)

Parses query string.

Parameters

$s

Return Value

array

Traits

SmartObject