Actions

Difference between revisions of "JURI/getQuery"

From Joomla! Documentation

(New page: Returns the query part of the URI represented by the JURI object. ===Syntax=== string getQuery( $toArray ) where: {| class="wikitable" !Argument !Data type !Description !Default |- |$toAr...)
 
m (See also: re-categorisation)
 
Line 42: Line 42:
 
* [[JURI/setQuery|JURI->setQuery]]
 
* [[JURI/setQuery|JURI->setQuery]]
 
* [[JURI/buildQuery|JURI->buildQuery]]
 
* [[JURI/buildQuery|JURI->buildQuery]]
<noinclude>[[Category:Development]][[Category:Framework]][[Category:JURI]]</noinclude>
+
<noinclude>[[Category:JURI]]</noinclude>

Latest revision as of 11:34, 9 August 2012

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