API16:JURI/parse
From Joomla! Documentation
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.
Contents |
Description
Parse a given URI and populate the class fields.
Syntax
parse($uri)
| Parameter Name | Default Value | Description |
|---|---|---|
| $uri | $uri The URI string to parse. |
Returns
boolean True on success.
Defined in
libraries/joomla/environment/uri.php
Importing
jimport( 'joomla.environment.uri' );
Source Body
public function parse($uri) { // Initialise variables $retval = false; // Set the original URI to fall back on $this->_uri = $uri; /* * Parse the URI and populate the object fields. If URI is parsed properly, * set method return value to true. */ if ($_parts = parse_url($uri)) { $retval = true; } //We need to replace & with & for parse_str to work right... if (isset ($_parts['query']) && strpos($_parts['query'], '&')) { $_parts['query'] = str_replace('&', '&', $_parts['query']); } $this->_scheme = isset ($_parts['scheme']) ? $_parts['scheme'] : null; $this->_user = isset ($_parts['user']) ? $_parts['user'] : null; $this->_pass = isset ($_parts['pass']) ? $_parts['pass'] : null; $this->_host = isset ($_parts['host']) ? $_parts['host'] : null; $this->_port = isset ($_parts['port']) ? $_parts['port'] : null; $this->_path = isset ($_parts['path']) ? $_parts['path'] : null; $this->_query = isset ($_parts['query'])? $_parts['query'] : null; $this->_fragment = isset ($_parts['fragment']) ? $_parts['fragment'] : null; //parse the query if (isset($_parts['query'])) { parse_str($_parts['query'], $this->_vars); } return $retval; }
[Edit See Also] SeeAlso:JURI/parse
Examples
<CodeExamplesForm />
