API15

JURI/root

From Joomla! Documentation

< API15:JURI
Revision as of 19:14, 24 March 2017 by JoomlaWikiBot (talk | contribs) (preparing for archive only)
(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 the root URI for the request.

[<! removed edit link to red link >]

<! removed transcluded page call, red link never existed >

Syntax[edit]

root($pathonly=false, $path=null)
Parameter Name Default Value Description
$pathonly false $pathonly If false, prepend the scheme, host and port information. Default is false.
$path null

Returns[edit]

string The root URI string

Defined in[edit]

libraries/joomla/environment/uri.php

Importing[edit]

jimport( 'joomla.environment.uri' );

Source Body[edit]

function root($pathonly = false, $path = null)
{
        static $root;

        // Get the scheme
        if(!isset($root))
        {
                $uri            =& JURI::getInstance(JURI::base());
                $root['prefix'] = $uri->toString( array('scheme', 'host', 'port') );
                $root['path']   = rtrim($uri->toString( array('path') ), '/\\');
        }

        // Get the scheme
        if(isset($path)) {
                $root['path']    = $path;
        }

        return $pathonly === false ? $root['prefix'].$root['path'].'/' : $root['path'];
}

[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >

Examples[edit]

Code Examples[edit]