Actions

Difference between revisions of "JURI/setFragment"

From Joomla! Documentation

(New page: Sets the fragment part of the URI represented by the JURI object. ===Syntax=== void setFragment( $anchor ) where: {| class="wikitable" !Argument !Data type !Description !Default |- |$anch...)
 
m (See also: re-categorisation)
 
Line 31: Line 31:
 
* [http://api.joomla.org/Joomla-Framework/Environment/JURI.html#setFragment JURI->setFragment on api.joomla.org]
 
* [http://api.joomla.org/Joomla-Framework/Environment/JURI.html#setFragment JURI->setFragment on api.joomla.org]
 
* [[JURI/getFragment|JURI->getFragment]]
 
* [[JURI/getFragment|JURI->getFragment]]
<noinclude>[[Category:Development]][[Category:Framework]][[Category:JURI]]</noinclude>
+
<noinclude>[[Category:JURI]]</noinclude>

Latest revision as of 11:35, 9 August 2012

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

Syntax

void setFragment( $anchor )

where:

Argument Data type Description Default
$anchor string Fragment to be added to the URI. This will replace any existing fragment.

Example

In this example, a URI object is created and a fragment is added to it.

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

would output

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

See also