Actions

JURI/setVar

From Joomla! Documentation

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.

Syntax

string setVar( $name, $value )

where:

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.

Example

In this example, a URI object is created and the task 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";
echo '- old value of task was ' . $u->setVar( 'task', 'save' ) . "\n";
echo 'After : ' . $u->toString();

would output

Before: http://fredbloggs:itsasecret@www.example.com:8080/path/to/Joomla/index.php?task=view&id=32#anchorthis
- old value of task was view
After : http://fredbloggs:itsasecret@www.example.com:8080/path/to/Joomla/index.php?task=save&id=32#anchorthis

See also