-1

I know, there are many ways. I wish you could give me many ways to let me choose.

David Snabel-Caunt
  • 57,804
  • 13
  • 114
  • 132
lovespring
  • 19,051
  • 42
  • 103
  • 153
  • 1
    and I wish I had an elephant stamp – Phil Aug 11 '11 at 08:00
  • 2
    *(suggested reading)* [What is wrong with using `$_REQUEST`](http://stackoverflow.com/questions/2142497/whats-wrong-with-using-request/2143042#2143042) – Gordon Aug 11 '11 at 08:01
  • This is not a real question. When you already know there is several ways to achieve this, pick one and be happy. If you are unsure which to pick, clarify what makes you doubt. Express your concerns. Otherwise, use the simplest thing that works. – Gordon Aug 11 '11 at 08:26

2 Answers2

3

I'm really not sure what you're after but from a controller context, there's a couple of ways to access request parameters (note, this is not the same as $_REQUEST).

$param = $this->getRequest()->getParam('param');
$param = $this->getRequest()->param; // provided the param name satisfies PHP object property rules for use in __get()
$param = $this->_getParam('param-name'); // same as above

From Zend_Controller_Request_Http::__get()

Access values contained in the superglobals as public members
Order of precedence: 1. GET, 2. POST, 3. COOKIE, 4. SERVER, 5. ENV

What the comment does not mention is that it first checks the internal "instance" parameters array.

Phil
  • 157,677
  • 23
  • 242
  • 245
2

From inside the controller you should use one of

$all = $this->getRequest()->getParams();
$one = $this->getRequest()->getParam('key');

$all = $this->_request->getParams();
$one = $this->_request->getParam('key');

$all = $this->_getAllParams();
$one = $this->_getParam('key');

Or from outside the controller (and after the front controller is loaded)

$front = Zend_Controller_Front::getInstance();
$all = $front->getRequest()->getParams();
$one = $front->getRequest()->getParam('key');
adlawson
  • 6,303
  • 1
  • 35
  • 46