Difference between revisions of "JURI/setVar"

From Joomla! Documentation

m (Example: small error in desc)
m (See also: re-categorisation)
Line 39: Line 39:
* [[JURI/getVar|JURI->getVar]]
* [[JURI/getVar|JURI->getVar]]
* [[JURI/delVar|JURI->delVar]]
* [[JURI/delVar|JURI->delVar]]

Latest revision as of 12:43, 9 August 2012

Sets an individual query item in the query part of the URI represented by the URI object. Returns the previous value of the query item if it existed.


string setVar( $name, $value )


Argument Data type Description Default
$name string Name of the query item to be set.
$value string Value of the query item to be set.


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

$uri = '';
$u =& JURI::getInstance( $uri );
echo 'Before: ' . $u->toString() . "\n";
echo '- old value of task was ' . $u->setVar( 'task', 'save' ) . "\n";
echo 'After : ' . $u->toString();

would output

- old value of task was view
After :

See also