API15

JURI/parse

From Joomla! Documentation

< API15:JURI
Revision as of 17:19, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== Parse a given URI and populate the class fields <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Parse a given URI and populate the class fields

[Edit Descripton]

Template:Description:JURI/parse

Syntax[edit]

parse($uri)
Parameter Name Default Value Description
$uri $uri The URI string to parse

Returns[edit]

boolean True on success

Defined in[edit]

libraries/joomla/environment/uri.php

Importing[edit]

jimport( 'joomla.environment.uri' );

Source Body[edit]

function parse($uri)
{
        //Initialize 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 = $this->_parseURL($uri)) {
                $retval = true;
        }

        //We need to replace &amp; with & for parse_str to work right...
        if(isset ($_parts['query']) && strpos($_parts['query'], '&amp;')) {
                $_parts['query'] = str_replace('&amp;', '&', $_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] Template:SeeAlso:JURI/parse

Examples[edit]

<CodeExamplesForm />