class Url (View source)

Constants

SCHEME_ALIGN

HOST_IDNA_ASCII

PATH_ASCII

PATH_RESOLVE

PATH_SLUG

PATH_UNICODE

SORT_QUERY

Properties

string $scheme
string $host
string $port
string $user
string $pass
string $path
string $query
string $fragment

Methods

__construct(string $url)

Parse URL

static 
setSchemePorts(array $ports)

Set default ports associated with specific schemes.

static 
setSlugDict(array $dict)

Set slug dictionary

static Url
application(bool $appendQuery)

Get Url instance from current url

Url
modify(int $flags)

Creates a new object with modified:

  • Scheme is modified if the SCHEME_ALIGN flag is used
  • Host is modified if the HOST_IDNA_ASCII flag is used
  • Path is modified if the PATH_ASCII, PATH_UNICODE, or PATH_SLUG flags are used
  • Query fields are sorted if the SORT_QUERY flag is used

Url
with(string $target, string $newValue)

Creates a new object with modified component

string|array|null
__get($component)

Get value for a URL component Note: $instance->query returns an array if the component is present

__set(string $component, string|array|null $value)

Set value for a URL component

string
__toString()

Returns a string encoding only what is necessary

Details

__construct(string $url)

Parse URL

Parameters

string $url

Exceptions

Exception

static setSchemePorts(array $ports)

Set default ports associated with specific schemes.

Parameters

array $ports

static setSlugDict(array $dict)

Set slug dictionary

Parameters

array $dict

static Url application(bool $appendQuery)

Get Url instance from current url

Parameters

bool $appendQuery

Return Value

Url

Url modify(int $flags)

Creates a new object with modified:

  • Scheme is modified if the SCHEME_ALIGN flag is used
  • Host is modified if the HOST_IDNA_ASCII flag is used
  • Path is modified if the PATH_ASCII, PATH_UNICODE, or PATH_SLUG flags are used
  • Query fields are sorted if the SORT_QUERY flag is used

Parameters

int $flags

Return Value

Url

Url with(string $target, string $newValue)

Creates a new object with modified component

Parameters

string $target
string $newValue

Return Value

Url

string|array|null __get($component)

Get value for a URL component Note: $instance->query returns an array if the component is present

Parameters

$component

Return Value

string|array|null

__set(string $component, string|array|null $value)

Set value for a URL component

Parameters

string $component
string|array|null $value

string __toString()

Returns a string encoding only what is necessary

Return Value

string