views:

50

answers:

2

I had a read of the documentation, but couldn't see an example of how it would be possible to use the variable in traditional PHP style of $_POST['var']

I'm pretty sure my URL is legit:

domain.com/module/controller/action/var/value/

Using the above as an example:

$var didn't work

$_POST['var'] didn't work

How is it done?

+2  A: 

$this->_request->getParam('paramName', $defaultValueToReturnIfParamIsNotSet);

robertbasic
+4  A: 

As presented in zend controller's documentation page you can retrieve parameters like this:

public function userinfoAction()
{
    $request = $this->getRequest();
    $username = $request->getParam('username');

    $username = $this->_getParam('username');
}

You should also note that request documentation states:

In order to do some of its work, getParam() actually retrieves from several sources. In order of priority, these include: user parameters set via setParam(), GET parameters, and finally POST parameters. Be aware of this when pulling data via this method.

If you wish to pull only from parameters you set via setParam(), use the getUserParam(). Additionally, as of 1.5.0, you can lock down which parameter sources will be searched. setParamSources() allows you to specify an empty array or an array with one or more of the values '_GET' or '_POST' indicating which parameter sources are allowed (by default, both are allowed); if you wish to restrict access to only '_GET' specify setParamSources(array('_GET')).

Jonas