Url: ezcUrlTools
[ ]
[ ]
[ ]
[ ]
[ ]
Class: ezcUrlTools
|
Class providing methods for URL parsing. [
source]
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).
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
string getCurrentUrl(
[
$source = null] )
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
For example, if $_SERVER has these fields:
1. $_SERVER = array(
2. 'HTTPS' => '1',
3. 'SERVER_NAME' => 'www.example.com',
4. 'SERVER_PORT' => 80,
5. 'REQUEST_URI' => '/index.php'
6. );
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
array(string=>mixed) parseQueryString(
array(string=>mixed)
$str )
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.
In the first case (parse_str()), $params will be:
1. array( 'foo' => array( 'bar' ), 'openid_nonce' => '123456' );
In the second case (ezcUrlTools::parseQueryString()), $params will be:
1. array( 'foo' => array( 'bar' ), 'openid.nonce' => '123456' );
Parameters
| Name |
Type |
Description |
$str |
array(string=>mixed) |
The string to parse |
Last updated: Mon, 05 Jan 2009