API16

JURI/toString

< 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

Returns full uri string.



Syntax

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

string The rendered URI string.

Defined in

libraries/joomla/environment/uri.php

Importing

jimport( 'joomla.environment.uri' );

Source Body

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



Examples

Code Examples


Advertisement