API15

JURI/toString

From Joomla! Documentation

< API15:JURI
Revision as of 17:19, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== Returns full uri string <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki> </span> ...)
(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]

Returns full uri string

[Edit Descripton]

Template:Description:JURI/toString

Syntax[edit]

toString($parts=array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment'))
Parameter Name Default Value Description
$parts array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment') $parts An array specifying the parts to render

Returns[edit]

string The rendered URI string

Defined in[edit]

libraries/joomla/environment/uri.php

Importing[edit]

jimport( 'joomla.environment.uri' );

Source Body[edit]

function toString($parts = array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment'))
{
        $query = $this->getQuery(); //make sure the query is created

        $uri = '';
        $uri .= in_array('scheme', $parts)  ? (!empty($this->_scheme) ? $this->_scheme.'://' : '') : '';
        $uri .= in_array('user', $parts)        ? $this->_user : '';
        $uri .= in_array('pass', $parts)        ? (!empty ($this->_pass) ? ':' : '') .$this->_pass. (!empty ($this->_user) ? '@' : '') : '';
        $uri .= in_array('host', $parts)        ? $this->_host : '';
        $uri .= in_array('port', $parts)        ? (!empty ($this->_port) ? ':' : '').$this->_port : '';
        $uri .= in_array('path', $parts)        ? $this->_path : '';
        $uri .= in_array('query', $parts)       ? (!empty ($query) ? '?'.$query : '') : '';
        $uri .= in_array('fragment', $parts)? (!empty ($this->_fragment) ? '#'.$this->_fragment : '') : '';

        return $uri;
}

[Edit See Also] Template:SeeAlso:JURI/toString

Examples[edit]

<CodeExamplesForm />