API16

JURI/parse

< API16:JURI

The "API16" 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

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 &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;
}



Examples

Code Examples


Advertisement