how to access paratmeter passed in request
how to access this paramvalue in controller..?
$router->map('Company', 'Company', array(
'controller' => 'companies',
'action' => 'add',
'paramkey' => 'paramvalue',
'anotherparam' => 'anotherv开发者_如何学编程alue'));
Plz help me
Try
$this->getRequest()->getParam('paramkey');
get one param:
$this->getRequest()->getParam('paramkey'[, 'default value']);
get all params:
$this->getRequest()->getAllParams();
or
$this->_getParam('paramkey'[, 'default value']);
$this->_getAllParams();
I`m using Zend Framework so method described in Zend_Action_Contoller:
/**
* Gets a parameter from the {@link $_request Request object}. If the
* parameter does not exist, NULL will be returned.
*
* If the parameter does not exist and $default is set, then
* $default will be returned instead of NULL.
*
* @param string $paramName
* @param mixed $default
* @return mixed
*/
protected function _getParam($paramName, $default = null)
if you are using CacePHP you can try
$this->params['paramkey'];
but I`m not sure it will work
精彩评论