JURI/setPath

From Joomla! Documentation
< JURI
Revision as of 12:42, 9 August 2012 by JoomlaWikiBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Sets the path part of the URI represented by the JURI object.

Syntax

void setPath( $path )

where:

Argument Data type Description Default
$path string Path to be added to the URI. This will replace any existing path.

Note that the path is cleaned before it is placed in the URI object. For example, these transformations would be done:

  • /foo/bar/../boo.php => /foo/boo.php
  • /foo/bar/../../boo.php => /boo.php
  • /foo/bar/.././/boo.php => /foo/boo.php

Example

In this example, a URI object is created and the path is then changed.

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

would output

Before: http://fredbloggs:itsasecret@www.example.com:8080/path/to/Joomla/index.php?task=view&id=32#anchorthat
After : http://fredbloggs:itsasecret@www.example.com:8080/administrator/components/com_contact/controller.php?task=view&id=32#anchorthat

See also

Personal tools
Namespaces

Variants
Actions
Navigation
Joomla! Sites
Toolbox