<p>The behaviour you're seeing is by design – <a href="https://craftcms.com/classreference/variables/HttpRequestVariable#getQuery-detail" rel="nofollow"><code>craft.request.getQuery()</code></a> will return all <code>GET</code> variables if it's called without arguments, whereas <a href="https://craftcms.com/classreference/variables/HttpRequestVariable#getParam-detail" rel="nofollow"><code>craft.request.getParam()</code></a> requires the <code>name</code> argument – i.e. <code>craft.request.getParam('foo')</code>.</p>

<p>The changelog notes for <a href="https://craftcms.com/changelog#build2465" rel="nofollow">build 1.3.2465</a> does reference a couple of issues related to these methods, but nothing suggesting any changes in regards to the required <code>name</code> argument for <code>getParam()</code>. Unfortunately, the <a href="https://github.com/pixelandtonic/Craft-Release" rel="nofollow">GitHub repo for Craft builds</a> doesn't go back as far as 1.3.2465, so I'm unable to verify this though.</p>

CC BY-SA 3.0
2016-02-19T12:44:57.570Z
The note in the changelog doesn't mean that all the params are being returned as one array (if not filtered down using the name argument), but that a single param can be an array. I'm no native english speaker, but I think you can read the note in both ways.
carlcs
CC BY-SA 3.0
2016-02-19T18:39:22.230Z
Thanks for clearing that up guys. So I'm right in thinking `request = craft.request.getParam()` would require an `if request.query` before it returns any array (as @carlcs mentions, a single parameter array). Is this correct? I've asked this because there are a couple of the Stack Exchange examples, so assumed they were interchangeable. Are either preferable? The dot notation feels a bit cleaner to me.
Rob
CC BY-SA 3.0
2016-02-19T18:46:07.913Z
No, you can't get an array back from getParam. Use getQuery or you have to get each one separatly with getParam(name), @Rob.
carlcs
CC BY-SA 3.0
2016-02-19T21:12:02.787Z
I swear I thought I'd seen an example on here using just that, but [it was yours @carlcs](http://craftcms.stackexchange.com/questions/12140/filter-entries-on-a-page-based-on-related-entry/12141#12141) which does, in fact, use `getQuery()`. I think for many parameters it's a more succinct way of doing things. That release note was confusing me ;)
Rob
CC BY-SA 3.0
2016-02-19T21:17:45.970Z
Yes, it has potential to confuse. I also wasn't sure if I might have posted here on SE, making use of craft.request.getParam in a wrong way. I searched for it, but didn't found anything. Puuuhh! :)
carlcs
CC BY-SA 3.0
2016-02-19T11:17:43.523Z
2016-02-19T11:17:43.523Z
Mats Mikkel Rummelhoff
<p><code>craft.request.getQuery()</code> returns:</p>

<pre><code>array (size=5)
  'tags' =&gt; string 'anxiety' (length=7)
  'maxPrice' =&gt; string '' (length=0)
  'sessions' =&gt; 
    array (size=4)
      0 =&gt; string 'email' (length=5)
      1 =&gt; string 'chat' (length=4)
      2 =&gt; string 'skype' (length=5)
      3 =&gt; string 'phone' (length=5)
  'hours' =&gt; 
    array (size=3)
      0 =&gt; string 'office' (length=6)
      1 =&gt; string 'evenings' (length=8)
      2 =&gt; string 'weekends' (length=8)
</code></pre>

<p>Whereas <code>craft.request.getParam()</code> throws an error:</p>

<blockquote>
  <p>PHP warning</p>
  
  <p>Missing argument 1 for Craft\HttpRequestVariable::getParam(), called in /home/vagrant/Sites/counselling-anywhere/craft/app/vendor/twig/twig/lib/Twig/Template.php on line 609 and defined</p>
</blockquote>

<p>This should have changed in <a href="https://craftcms.com/changelog#build2465" rel="nofollow">Build #2465</a> right? I'm assuming it'll still work the same, but it's confusing that they don't return the same results.</p>

<p>Is this by design?</p>

<array><request><params><debugging>
Empty .getParam() does not return an array with dump()
# Empty .getParam() does not return an array with dump()

(Asked by: username_0 on 2016-02-18)

craft.request.getQuery() returns:
array (size=5)
  'tags' => string 'anxiety' (length=7)
  'maxPrice' => string '' (length=0)
  'sessions' => 
    array (size=4)
      0 => string 'email' (length=5)
      1 => string 'chat' (length=4)
      2 => string 'skype' (length=5)
      3 => string 'phone' (length=5)
  'hours' => 
    array (size=3)
      0 => string 'office' (length=6)
      1 => string 'evenings' (length=8)
      2 => string 'weekends' (length=8)

Whereas craft.request.getParam() throws an error:

PHP warning
Missing argument 1 for Craft\HttpRequestVariable::getParam(), called in /home/vagrant/Sites/counselling-anywhere/craft/app/vendor/twig/twig/lib/Twig/Template.php on line 609 and defined

This should have changed in Build #2465 right? I'm assuming it'll still work the same, but it's confusing that they don't return the same results.
Is this by design?

**Tags:** array, request, params, debugging

---

## 1 answers

### Answer by username_1 on 2016-02-19. Score: 3 | Accepted answer

The behaviour you're seeing is by design – [`craft.request.getQuery()`](https://craftcms.com/classreference/variables/HttpRequestVariable#getQuery-detail) will return all `GET` variables if it's called without arguments, whereas [`craft.request.getParam()`](https://craftcms.com/classreference/variables/HttpRequestVariable#getParam-detail) requires the `name` argument – i.e. `craft.request.getParam('foo')`.

The changelog notes for [build 1.3.2465](https://craftcms.com/changelog#build2465) does reference a couple of issues related to these methods, but nothing suggesting any changes in regards to the required `name` argument for `getParam()`. Unfortunately, the [GitHub repo for Craft builds](https://github.com/pixelandtonic/Craft-Release) doesn't go back as far as 1.3.2465, so I'm unable to verify this though.

> **Comments:**
> **username_2**: The note in the changelog doesn't mean that all the params are being returned as one array (if not filtered down using the name argument), but that a single param can be an array. I'm no native english speaker, but I think you can read the note in both ways.  
> **username_0**: Thanks for clearing that up guys. So I'm right in thinking `request = craft.request.getParam()` would require an `if request.query` before it returns any array (as @carlcs mentions, a single parameter array). Is this correct? I've asked this because there are a couple of the Stack Exchange examples, so assumed they were interchangeable. Are either preferable? The dot notation feels a bit cleaner to me.  
> **username_2**: No, you can't get an array back from getParam. Use getQuery or you have to get each one separatly with getParam(name), @Rob.  
> **username_0**: I swear I thought I'd seen an example on here using just that, but [it was yours @carlcs](http://craftcms.stackexchange.com/questions/12140/filter-entries-on-a-page-based-on-related-entry/12141#12141) which does, in fact, use `getQuery()`. I think for many parameters it's a more succinct way of doing things. That release note was confusing me ;)  
> **username_2**: Yes, it has potential to confuse. I also wasn't sure if I might have posted here on SE, making use of craft.request.getParam in a wrong way. I searched for it, but didn't found anything. Puuuhh! :)  

---

