Net_URL2
[ class tree: Net_URL2 ] [ index: Net_URL2 ] [ all elements ]

Class: Net_URL2

Source Location: /Net_URL2-2.2.0/Net/URL2.php

Class Overview


Represents a URL as per RFC 3986.


Author(s):

Version:

  • Release: 2.2.0

Copyright:

  • 2007-2009 Peytz & Co. A/S

Methods


Inherited Variables

Inherited Methods


Class Details

[line 57]
Represents a URL as per RFC 3986.


[ Top ]


Method Detail

__construct (Constructor)   [line 148]

Net_URL2 __construct( string $url, [array $options = array()])

Constructor.
  • Access: public
  • Uses: self::parseUrl()

Parameters:

string   $url   —  an absolute or relative URL
array   $options   —  an array of OPTION_xxx constants

[ Top ]

buildQuery   [line 1128]

string buildQuery( array $data, string $separator, [string $key = null])

A simple version of http_build_query in userland. The encoded string is percentage encoded according to RFC 3986.
  • Access: protected

Parameters:

array   $data   —  An array, which has to be converted into QUERY_STRING. Anything is possible.
string   $separator   —  Separator self::OPTION_SEPARATOR_OUTPUT
string   $key   —  For stacked values (arrays in an array).

[ Top ]

getAuthority   [line 346]

string|bool getAuthority( )

Returns the authority part, i.e. [ userinfo "@" ] host [ ":" port ], or false if there is no authority.
  • Access: public

[ Top ]

getCanonical   [line 1052]

string getCanonical( )

Returns a Net_URL2 instance representing the canonical URL of the currently executing PHP script.
  • Throws: Exception
  • Access: public

[ Top ]

getFragment   [line 459]

string|bool getFragment( )

Returns the fragment name, or false if "#" is not present in the URL.
  • Access: public

[ Top ]

getHost   [line 296]

string|bool getHost( )

Returns the host part, or false if there is no authority part, e.g.

relative URLs.

  • Return: a hostname, an IP address, or false
  • Access: public

[ Top ]

getNormalizedURL   [line 763]

string getNormalizedURL( )

Returns a normalized string representation of this URL. This is useful for comparison of URLs.
  • Access: public

[ Top ]

getOption   [line 1111]

mixed getOption( string $optionName)

Returns the value of the specified option.
  • Access: public

Parameters:

string   $optionName   —  The name of the option to retrieve

[ Top ]

getPassword   [line 249]

string|bool getPassword( )

Returns the password part of the userinfo part (the part after the first ":"), or false if there is no userinfo part (i.e. the URL does not contain "@" in front of the hostname) or the userinfo part does not contain ":".
  • Access: public

[ Top ]

getPath   [line 409]

string getPath( )

Returns the path part (possibly an empty string).
  • Access: public

[ Top ]

getPort   [line 321]

string|bool getPort( )

Returns the port number, or false if there is no port number specified, i.e. if the default port is to be used.
  • Access: public

[ Top ]

getQuery   [line 434]

string|bool getQuery( )

Returns the query string (excluding the leading "?"), or false if "?" is not present in the URL.

[ Top ]

getQueryVariables   [line 485]

array getQueryVariables( )

Returns the query string like an array as the variables would appear in $_GET in a PHP script. If the URL does not contain a "?", an empty array is returned.
  • Access: public

[ Top ]

getRequested   [line 1089]

$this getRequested( )

Returns a Net_URL2 instance representing the URL used to retrieve the current request.
  • Throws: Exception
  • Access: public

[ Top ]

getRequestedURL   [line 1077]

string getRequestedURL( )

Returns the URL used to retrieve the current request.
  • Access: public

[ Top ]

getScheme   [line 206]

string|bool getScheme( )

Returns the scheme, e.g. "http" or "urn", or false if there is no scheme specified, i.e. if this is a relative URL.
  • Access: public

[ Top ]

getURL   [line 699]

string getURL( )

Returns a string representation of this URL.
  • Access: public

[ Top ]

getUser   [line 234]

string|bool getUser( )

Returns the user part of the userinfo part (the part preceding the first ":"), or false if there is no userinfo part.
  • Access: public

[ Top ]

getUserinfo   [line 262]

string|bool getUserinfo( )

Returns the userinfo part, or false if there is none, i.e. if the authority part does not contain "@".
  • Access: public

[ Top ]

isAbsolute   [line 868]

bool isAbsolute( )

Returns whether this instance represents an absolute URL.
  • Access: public

[ Top ]

normalize   [line 779]

void normalize( )

Normalizes the URL

See RFC 3986, Section 6. Normalization and Comparison


[ Top ]

parseUrl   [line 1166]

void parseUrl( string $url)

This method uses a regex to parse the url into the designated parts.
  • See: Net_URL2::__construct()
  • Access: protected
  • Uses: self::$_scheme, - self::setAuthority(), self::$_path, self::$_query, self::$_fragment

Parameters:

string   $url   —  URL

[ Top ]

removeDotSegments   [line 976]

string removeDotSegments( string $path)

Removes dots as described in RFC 3986, section 5.2.4, e.g.

"/foo/../bar/baz" => "/bar/baz"

  • Return: a path
  • Access: public

Parameters:

string   $path   —  a path

[ Top ]

resolve   [line 882]

$this resolve( Net_URL2|string $reference)

Returns an Net_URL2 instance representing an absolute URL relative to this URL.
  • Throws: Exception
  • Access: public

Parameters:

Net_URL2|string   $reference   —  relative URL

[ Top ]

setAuthority   [line 377]

$this setAuthority( string|bool $authority)

Sets the authority part, i.e. [ userinfo "@" ] host [ ":" port ]. Specify false if there is no authority.
  • Access: public

Parameters:

string|bool   $authority   —  a hostname or an IP address, possibly with userinfo prefixed and port number appended, e.g. "foo:bar@example.org:81".

[ Top ]

setFragment   [line 472]

$this setFragment( string|bool $fragment)

Sets the fragment name. Specify false if "#" is not present in the URL.
  • Access: public

Parameters:

string|bool   $fragment   —  a fragment excluding the leading "#", or false

[ Top ]

setHost   [line 309]

$this setHost( string|bool $host)

Sets the host part. Specify false if there is no authority part, e.g.

relative URLs.

  • Access: public

Parameters:

string|bool   $host   —  a hostname, an IP address, or false

[ Top ]

setPath   [line 421]

$this setPath( string $path)

Sets the path part (possibly an empty string).
  • Access: public

Parameters:

string   $path   —  a path

[ Top ]

setPort   [line 334]

$this setPort( string|bool $port)

Sets the port number. Specify false if there is no port number specified, i.e. if the default port is to be used.
  • Access: public

Parameters:

string|bool   $port   —  a port number, or false

[ Top ]

setQuery   [line 448]

$this setQuery( string|bool $query)

Sets the query string (excluding the leading "?"). Specify false if "?" is not present in the URL.

Parameters:

string|bool   $query   —  a query string, e.g. "foo=1&bar=2"

[ Top ]

setQueryVariable   [line 672]

$this setQueryVariable( string $name, mixed $value)

Sets the specified variable in the query string.
  • Access: public

Parameters:

string   $name   —  variable name
mixed   $value   —  variable value

[ Top ]

setQueryVariables   [line 651]

$this setQueryVariables( array $array)

Sets the query string to the specified variable in the query string.
  • Access: public

Parameters:

array   $array   —  (name => value) array

[ Top ]

setScheme   [line 222]

$this setScheme( string|bool $scheme)

Sets the scheme, e.g. "http" or "urn". Specify false if there is no scheme specified, i.e. if this is a relative URL.

Parameters:

string|bool   $scheme   —  e.g. "http" or "urn", or false if there is no scheme specified, i.e. if this is a relative URL

[ Top ]

setUserinfo   [line 276]

$this setUserinfo( string|bool $userinfo, [string|bool $password = false])

Sets the userinfo part. If two arguments are passed, they are combined in the userinfo part as username ":" password.
  • Access: public

Parameters:

string|bool   $userinfo   —  userinfo or username
string|bool   $password   —  optional password, or false

[ Top ]

unsetQueryVariable   [line 687]

void unsetQueryVariable( string $name)

Removes the specified variable from the query string.
  • Access: public

Parameters:

string   $name   —  a query string variable, e.g. "foo" in "?foo=1"

[ Top ]

urlencode   [line 1036]

string urlencode( string $string)

Percent-encodes all non-alphanumeric characters except these: _ . - ~ Similar to PHP's rawurlencode(), except that it also encodes ~ in PHP 5.2.x and earlier.
  • Access: public

Parameters:

string   $string   —  string to encode

[ Top ]

__get   [line 190]

mixed __get( string $var)

Magic Getter.

This is the magic get method to retrieve the private variable that was set by either __set() or it's setter...

  • Return: Either a boolean false if the property is not set or the value of the private property.
  • Access: public

Parameters:

string   $var   —  The property name to retrieve.

[ Top ]

__set   [line 170]

void __set( string $var, mixed $arg)

Magic Setter.

This method will magically set the value of a private variable ($var) with the value passed as the args

  • Access: public

Parameters:

string   $var   —  The private variable to set.
mixed   $arg   —  An argument of any type.

[ Top ]

__toString   [line 752]

string __toString( )

Returns a string representation of this URL.

[ Top ]


Documentation generated on Mon, 11 Mar 2019 16:01:49 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.