Actions

Difference between revisions of "JURI/getInstance"

From Joomla! Documentation

(New page: Static method which either returns a reference to the global JURI object, only creating it if it doesn't already exist, or which creates a new object representing the URI passed to it as a...)
 
m (See also: re-categorisation)
 
Line 36: Line 36:
 
* [http://api.joomla.org/Joomla-Framework/Environment/JURI.html#getInstance JURI->getInstance on api.joomla.org]
 
* [http://api.joomla.org/Joomla-Framework/Environment/JURI.html#getInstance JURI->getInstance on api.joomla.org]
 
* [[JFactory/getURI|JFactory::getURI]]
 
* [[JFactory/getURI|JFactory::getURI]]
<noinclude>[[Category:Development]][[Category:Framework]][[Category:JURI]]</noinclude>
+
<noinclude>[[Category:JURI]]</noinclude>

Latest revision as of 11:33, 9 August 2012

Static method which either returns a reference to the global JURI object, only creating it if it doesn't already exist, or which creates a new object representing the URI passed to it as a parameter. The global URI object represents the URI that caused the current page to be rendered.

Contents

Syntax

object &getInstance( $uri )

where:

Argument Data type Description Default
$uri string URI to be represented by the JURI object. If this is 'SERVER' then the request URI is assumed. 'SERVER'

Example 1

In this example, a URI object is created and then converted back to string form.

$uri = 'http://fredbloggs:itsasecret@www.example.com:8080/path/to/Joomla/index.php?task=view&id=32#anchorthis';
$u =& JURI::getInstance( $uri );
echo 'URI is ' . $u->toString() . "\n";

would output

URI is http://fredbloggs:itsasecret@www.example.com:8080/path/to/Joomla/index.php?task=view&id=32#anchorthis

Example 2

To obtain the current request URI this method can be called with no arguments. This has the same effect as calling JFactory::getURI().

$u =& JURI::getInstance();
echo 'Request URI is ' . $u->toString() . "\n";

might output

Request URI is http://localhost/joomla/index.php?option=com_content&view=article&id=1&Itemid=50

See also