How to get url parameter in controller

http://www.example.com/api/test?a=1&b=2

I want to get the value of a, b in testAction of ApiController, I tried this:

$a = $this->request->get('a'); and $a = $this->request->getQuery('a');

It's not working. I searched and peaples say using getQuery should work, but, .... I need help....

Does it have a relationship with nginx config? Thanks



37.8k

Hi

You try die after the code abobe, such that

$a = $this->request->get('a'); 
$b = $this->request->getQuery('a');
var_dump($a);
var_dump($b);
die();