CakePHP 1.3 - 提取 URL GET 参数
CakePHP 1.3 - Extract URL GET parameters
我的 CakePHP 1.3.2 应用程序使用类似 URLs:
/controller/action/name1:value1/name2:value2.html
我正在尝试提取之前名称指定的 :
符号后的值。我可以使用 $this->params['url']
毫无问题地看到整个 URL,但是,我无法使用 $this->params['name1']
或 $this->params['url']['name1']
获取值本身。有什么建议吗?
URL: /contents/view/chapter:models/section:associations Mapping:
ContentsController->view(); $this->passedArgs['chapter'] = 'models';
$this->passedArgs['section'] = 'associations';
$this->params['named']['chapter'] = 'models';
$this->params['named']['section'] = 'associations';
所以你应该使用:
$this->params['named']['name1']
$this->params['named']['name2']
我的 CakePHP 1.3.2 应用程序使用类似 URLs:
/controller/action/name1:value1/name2:value2.html
我正在尝试提取之前名称指定的 :
符号后的值。我可以使用 $this->params['url']
毫无问题地看到整个 URL,但是,我无法使用 $this->params['name1']
或 $this->params['url']['name1']
获取值本身。有什么建议吗?
URL: /contents/view/chapter:models/section:associations Mapping:
ContentsController->view(); $this->passedArgs['chapter'] = 'models';
$this->passedArgs['section'] = 'associations';
$this->params['named']['chapter'] = 'models';
$this->params['named']['section'] = 'associations';
所以你应该使用:
$this->params['named']['name1']
$this->params['named']['name2']