Apache Zeta Components Manual :: Docs For Class ezcUrlTools
Url::ezcUrlTools
Class ezcUrlTools
Class providing methods for URL parsing.
Static methods contained in this class:
- parseQueryString() - It implements the functionality of the PHP function parse_str(), but without converting dots to underscores in parameter names.
- getCurrentUrl() - Returns the current URL as a string from the provided array (by default $_SERVER).
Source for this file: /Url/src/url_tools.php
Version: | //autogen// |
Method Summary
public static string |
getCurrentUrl(
[ $source
= null] )
Returns the current URL as a string from the array $source (by default $_SERVER). |
public static array(string=>mixed) |
parseQueryString(
$str
)
Parses the provided string and returns an associative array structure. |
Methods
getCurrentUrl
Returns the current URL as a string from the array $source (by default $_SERVER).
The following fields are used in building the URL:
- HTTPS - determines the scheme ('http' or 'https'). 'https' only if the 'HTTPS' field is set or if it is 'on' or '1'
- SERVER_NAME
- SERVER_PORT - determines if port is default (80 = do not include port) or not default (other than 80 = include port)
- REQUEST_URI
- $_SERVER = array(
- 'HTTPS' => '1',
- 'SERVER_NAME' => 'www.example.com',
- 'SERVER_PORT' => 80,
- 'REQUEST_URI' => '/index.php'
- );
Then by calling this function (with no parameters), this URL will be returned: 'http://www.example.com/index.php'.
The source of the URL parts can be changed to be other than $_SERVER by specifying an array parameter when calling this function.
Parameters:
Name | Type | Description |
---|---|---|
$source |
array(string=>mixed) | The default array source, default $_SERVER |
parseQueryString
Parses the provided string and returns an associative array structure.
It implements the functionality of the PHP function parse_str(), but without converting dots to underscores in parameter names.
Example:
- $str = 'foo[]=bar&openid.nonce=123456';
In the first case (parse_str()), $params will be:
- array( 'foo' => array( 'bar' ), 'openid_nonce' => '123456' );
In the second case (ezcUrlTools::parseQueryString()), $params will be:
- array( 'foo' => array( 'bar' ), 'openid.nonce' => '123456' );
Parameters:
Name | Type | Description |
---|---|---|
$str |
array(string=>mixed) | The string to parse |