class Url extends Url (View source)

URL class using the HTTP environment by default.

NOTE: This class has been added in v3.0.0.

Always adds http\Url::FROM_ENV to the $flags constructor argument. See also http\Url.

Constants

REPLACE

Replace parts of the old URL with parts of the new.

JOIN_PATH

Whether a relative path should be joined into the old path.

JOIN_QUERY

Whether the querystrings should be joined.

STRIP_USER

Strip the user information from the URL.

STRIP_PASS

Strip the password from the URL.

STRIP_AUTH

Strip user and password information from URL (same as STRIP_USER|STRIP_PASS).

STRIP_PORT

Do not include the port.

STRIP_PATH

Do not include the URL path.

STRIP_QUERY

Do not include the URL querystring.

STRIP_FRAGMENT

Strip the fragment (hash) from the URL.

STRIP_ALL

Strip everything except scheme and host information.

FROM_ENV

Import initial URL parts from the SAPI environment.

SANITIZE_PATH

Whether to sanitize the URL path (consolidate double slashes, directory jumps etc.)

PARSE_MBUTF8

Parse UTF-8 encoded multibyte sequences.

PARSE_MBLOC

Parse locale encoded multibyte sequences (on systems with wide character support).

PARSE_TOIDN

Parse and convert multibyte hostnames according to IDNA (with IDNA support).

PARSE_TOIDN_2003

Explicitly request IDNA2003 implementation if available (libidn, idnkit or ICU).

PARSE_TOIDN_2008

Explicitly request IDNA2008 implementation if available (libidn2, idnkit2 or ICU).

PARSE_TOPCT

Percent encode multibyte sequences in the userinfo, path, query and fragment parts of the URL.

IGNORE_ERRORS

Continue parsing when encountering errors.

SILENT_ERRORS

Suppress errors/exceptions.

STDFLAGS

Standard flags used by default internally for e.g. http\Message::setRequestUrl().

Enables joining path and query, sanitizing path, multibyte/unicode, international domain names and transient percent encoding.

Properties

string $scheme

The URL's scheme.

from  Url
string $user

Authenticating user.

from  Url
string $pass

Authentication password.

from  Url
string $host Hostname/domain. from  Url
string $port Port. from  Url
string $path

URL path.

from  Url
string $query

URL querystring.

from  Url
string $fragment

URL fragment (hash).

from  Url

Methods

__construct(mixed $old_url = null, mixed $new_url = null, int $flags = 0)

Create an instance of an http\Url.

from  Url
string
__toString()

String cast handler. Alias of http\Url::toString().

from  Url
Url
mod(mixed $parts, int $flags = \http\Url::JOIN_PATH | \http\Url::JOIN_QUERY | \http\Url::SANITIZE_PATH)

Clone this URL and apply $parts to the cloned URL.

from  Url
array
toArray()

Retrieve the URL parts as array.

from  Url
string
toString()

Get the string prepresentation of the URL.

from  Url

Details

__construct(mixed $old_url = null, mixed $new_url = null, int $flags = 0)

Create an instance of an http\Url.

NOTE: Prior to v3.0.0, the default for the $flags parameter was http\Url::FROM_ENV.

See also http\Env\Url.

Parameters

mixed $old_url

Initial URL parts. Either an array, object, http\Url instance or string to parse.

mixed $new_url

Overriding URL parts. Either an array, object, http\Url instance or string to parse.

int $flags

The modus operandi of constructing the url. See http\Url constants.

Exceptions

InvalidArgumentException
BadUrlException

string __toString()

String cast handler. Alias of http\Url::toString().

Return Value

string

the URL as string.

Url mod(mixed $parts, int $flags = \http\Url::JOIN_PATH | \http\Url::JOIN_QUERY | \http\Url::SANITIZE_PATH)

Clone this URL and apply $parts to the cloned URL.

NOTE: This method returns a clone (copy) of this instance.

Parameters

mixed $parts

New URL parts.

int $flags

Modus operandi of URL construction. See http\Url constants.

Return Value

Url clone.

Exceptions

InvalidArgumentException
BadUrlException

array toArray()

Retrieve the URL parts as array.

Return Value

array

the URL parts.

string toString()

Get the string prepresentation of the URL.

Return Value

string

the URL as string.