Packages » Package util » Class URL

Class URL

Declaration:
<? class URL ?>

Description:
The URL class represents an URL and provides a way to relocate it to new places taking into account absolute/relative URLs, paths etc. This class provides support for things like ports, subprotocols, user name and password, query strings and references. This class gives an easy access to different parts of an URL, so relocation is really straighforward. When constucting an URL, keep in mind that protocol and host will be converted to lower case; everything else will retain case. So, when comparing URLs, www.somehost.com/myFolder doesn't equal www.somehost.com/myfolder, however, it equals Www.SomeHost.Com/myFolder

Authors:
  • Dennis Popel
  • Mariyan Gracon (aka marik)

Properties:

Methods:
  • __construct()
    The sole constructor that creates a new URL from supplied location
  • equals()
    Tests whether two URLs are equal. Two URLs are equal if they have all fields equal, possibly except for ref
  • getDefaultPort()
  • getFullPath()
  • getURI()
    This function returns path + resource + query string + ref
  • isWellformed()
    Tests whether two URLs are equal. Two URLs are equal if they have all fields equal, possibly except for ref
  • relocate()
    Returns a new URL to a new location which can be:
    1. Absolute (if protocol specified) - $newLocation
    2. Absolute path (if no protocol, starts with "/") - will point to a new path and resource
    3. Relative path (if starts with anything, is not a query, but contains a path separator "/"
    4. Another resource if all above fails
  • toString()
    This method returns the properly formatted URL (the exact location used to construct this URL or with modified parts if appropriate)