JURI/setPath
From Joomla! Documentation
< JURI(Difference between revisions)
(New page: Sets the path part of the URI represented by the JURI object. ===Syntax=== void setPath( $path ) where: {| class="wikitable" !Argument !Data type !Description !Default |- |$path |string |...) |
m (→See also: re-categorisation) |
||
| Line 36: | Line 36: | ||
* [http://api.joomla.org/Joomla-Framework/Environment/JURI.html#setPath JURI->setPath on api.joomla.org] | * [http://api.joomla.org/Joomla-Framework/Environment/JURI.html#setPath JURI->setPath on api.joomla.org] | ||
* [[JURI/getPath|JURI->getPath]] | * [[JURI/getPath|JURI->getPath]] | ||
| − | <noinclude> | + | <noinclude>[[Category:JURI]]</noinclude> |
Latest revision as of 12:42, 9 August 2012
Sets the path part of the URI represented by the JURI object.
[edit] 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
[edit] 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