API15

JURI/root: Difference between revisions

From Joomla! Documentation

m removing red link to edit, no existant pages
m preparing for archive only
 
Line 63: Line 63:


===Examples===
===Examples===
<CodeExamplesForm />
=== Code Examples ===
<dpl>
<dpl>
  noresultsheader=\n
  noresultsheader=\n
  category=root
  category=root
  category=JURI
  category=JURI
  category=CodeExample
  namespace=CodeExample
  category=MethodExample
  category=MethodExample
  include=*
  include=*

Latest revision as of 01:14, 25 March 2017

Description

Returns the root URI for the request.

[<! removed edit link to red link >]

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

Syntax

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

string The root URI string

Defined in

libraries/joomla/environment/uri.php

Importing

jimport( 'joomla.environment.uri' );

Source Body

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

Code Examples