Actions

JURI/base

From Joomla! Documentation

Revision as of 12:07, 1 September 2009 by Chris Davenport (Talk | contribs)

A static method that returns the base URI of the Joomla site. If Joomla has been installed in the web server's document root then this method will return "/" for the path.

Contents

Syntax

string base( $pathonly )

where:

Argument Data type Description Default
$pathonly boolean If true then only the path to the Joomla site is returned; otherwise the scheme, host and port are prepended to the path. Note that when true the URI returned has a trailing "/", but when false the trailing "/" is omitted. false

Note

In a template you can use the shortcut $this->baseurl instead of JURI::base( true ).

Example

In this example, the Joomla site URI is shown with both values of the argument.

echo 'Joomla base URI is ' . JURI::base() . "\n";
echo 'Joomla base URI (path only) is ' . JURI::base( true ) . "\n";

might output

Joomla base URI is http://localhost/joomla/
Joomla base URI (path only) is /joomla

See also