2012-09-13 36 views
-1

我正在使用CakePhp2並試圖從url中獲取變量的值。CakePhp2:如何獲得像foo:bar/foo2:bar2/...這樣的url變量?

我的網址看起來像controller/action/foo:bar/foo2:bar2/foo3:bar3

當我使用$this->request['foo'] CakePhp說「未定義索引」。

任何想法找到foo,foo2和foo3的值?

+0

嘗試創建一個var_dump($ this-> request)並查看打印內容 –

回答

2

檢查有關命名參數的文檔。 它很有可能會在

$this->request->params['named'] 

或更容易/清潔劑的2.X:

$this->request->named 

所以調試($這個 - >請求 - >命名)瞭解詳情。

+0

您正在使用命名參數:http://book.cakephp.org/2.0/en/controllers/request-response.html# cakerequest –

0

嘗試

$this->passedArgs 
OR 
$this->request->params['pass'] 

你要訪問傳遞的參數。

+0

但他說的是命名參數,沒有通過! – mark

相關問題