Reputation: 1593
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?
Upvotes: 0
Views: 178
Reputation: 3020
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 viasetParam()
,GET
parameters, and finallyPOST
parameters. Be aware of this when pulling data via this method.If you wish to pull only from parameters you set via
setParam()
, use thegetUserParam()
. 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' specifysetParamSources(array('_GET'))
.
Upvotes: 4
Reputation: 4335
$this->_request->getParam('paramName', $defaultValueToReturnIfParamIsNotSet);
Upvotes: 2