2011-05-10 125 views
0

這是我第一次到Zend.Having這個索引操作方法:Zend的檢索URL參數

class IndexController extends Zend_Controller_Action 
{ 
public function indexAction() 
{ 
    $this->view->variable="I'm testing my controller"; 
    if($this->_request->isGet()) 
    { 
     $name=$this->_request->getQuery('mykey'); 
     $this->view->name=$name; 
    } 
} 
} 

這種觀點index.phtml:

echo $this->variable; 
if (isset($this->name)) 
{echo $this->name;} 

如果我輸入這個網址:

http://localhost/index/index/mykey/2

我不應該在索引視圖中看到「2」輸出嗎? 我只看到「我正在測試我的控制器」;

P.s.需要交代超過液=)

感謝

盧卡

回答

2

使用

$this->_getParam ('mykey', 0); 

代替。

+0

謝謝,但是我的代碼出了什麼問題? – luca 2011-05-10 15:48:37

+0

$ this - > _ request-> getQuery('mykey');是不是一個正確的方法來做你想做的。 – akond 2011-05-10 15:49:59

+0

可否請您指出我的參考或只是告訴我爲什麼不正確?再次感謝 – luca 2011-05-10 15:55:31