Zend Framework Action: GET Parameters

Zend Framework Action Step By Step Tutorial - Part 4: Now, we talk last part or URL in Zend Framework, parameters. Ok, what the rule in Zend Framework? Look this URL sample:

http://hostname/user/name/username/wiwit/gender/man

We can interpret like this:
1. Controller = user
2. Action = name
3. username = wiwit
4. gender = man

What is your conclusion? Yeah, we have general formula like this:
1 http://hostname/controller/action/var1/value1/var2/value2/...

How to catch the parameters? Ok, we can learn from sample. Open UserController.php within application/controller. Update became like this:
01 <?php
02 require_once 'Zend/Controller/Action.php';
03
04 class UserController extends Zend_Controller_Action
05 {
06 public function indexAction()
07 {
08 $this->view->assign('name', 'Wiwit');
09 $this->view->assign('title', 'Hello');
10 }
11
12 public function nameAction()
13 {
14
15 $request = $this->getRequest();
16 $this->view->assign('name', $request->getParam('username'));
17 $this->view->assign('gender', $request->getParam('gender'));
18
19 $this->view->assign('title', 'User Name');
20 }
21 }
22 ?>

Give attention at line 15-17. It is clear, isn't it?

你可能感兴趣的:(职场,framework,get,action,Parameters,Zend,休闲)