Zend Framework and Options
Is there a way to view all submitted parameters if I don't know their name?
For example, I sent these parameters:
- id = 1 (GET)
- name = 'John' (GET)
- surname = 'Smith' (GET)
Example
$request = $this->getRequest();
echo $request->getParam[0]; // Will output 1
echo $request->getParam[1]; // Will output 'John'
echo $request->getParam[2]; // Will output 'Smith'
Thank!
(I am not a native English speaker.)
+2
source to share
2 answers
$request = $this->getRequest();
print_r($request->getQuery()); // returns the entire $_GET array
print_r($request->getQuery("foo")); // retrieve a single member of the $_GET array
So, to programmatically program the names and values โโof the parameters, for example, in a simple loop:
foreach($request->getQuery() as $key => $value) {
echo "Key is: " . $key . " and value is: " . $value . '<br />';
}
Check out the API docs for Zend_Controller_Request_Http
.
+1
source to share