Actions

JURI/getVar

From Joomla! Documentation

Revision as of 11:34, 9 August 2012 by JoomlaWikiBot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Returns an individual query item value from the query part of the URI represented by the URI object.

Syntax

string getVar( $name, $default )

where:

Argument Data type Description Default
$name string Name of the query item. null
$default string Default value that will be returned if the named query item does not exist. null

Example

$uri = 'http://fredbloggs:itsasecret@www.example.com:8080/path/to/Joomla/index.php?task=view&id=32#anchorthis';
$u =& JURI::getInstance( $uri );
echo 'task is ' . $u->getVar( 'task', 'save' ) . "\n";
echo '  id is ' . $u->getVar( 'id' ) . "\n";
echo ' act is ' . $u->getVar( 'act', 'logout' ) . "\n";

would output

task is view
  id is 32
 act is logout

See also