Actions

JURI/getQuery

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 the query part of the URI represented by the JURI object.

Contents

Syntax

string getQuery( $toArray )

where:

Argument Data type Description Default
$toArray Boolean If true then the query items are returned as an associative array; otherwise they are returned as a string. false

Example 1

In this example, the query part of the URI represented by the URI object is returned as a string.

$uri = 'http://fredbloggs:itsasecret@www.example.com:8080/path/to/Joomla/index.php?task=view&id=32#anchorthis';
$u =& JURI::getInstance( $uri );
echo 'Query is ' . $u->getQuery();

would output

Query is task=view&id=32

Example 2

In this example, the query part of the URI represented by the URI object is returned as an array of query items.

$uri = 'http://fredbloggs:itsasecret@www.example.com:8080/path/to/Joomla/index.php?task=view&id=32#anchorthis';
$u =& JURI::getInstance( $uri );
print_r( $u->getQuery( true ) );

would output

Array
(
    [task] => view
    [id] => 32
)

See also