【问题标题】:CakePHP 1.3 - Extract URL GET parametersCakePHP 1.3 - 提取 URL GET 参数
【发布时间】:2015-06-18 09:26:08
【问题描述】:
我有使用类似 URL 的 CakePHP 1.3.2 应用程序:
/controller/action/name1:value1/name2:value2.html
我正在尝试提取之前名称指定的 : 符号之后的值。我可以使用$this->params['url'] 毫无问题地查看整个 URL,但是,我无法使用$this->params['name1'] 或$this->params['url']['name1'] 来获取值本身。有什么建议吗?
【问题讨论】:
标签:
php
url
cakephp
get
cakephp-1.3
【解决方案1】:
来自Cakephp 1.3 book:
网址:/contents/view/chapter:models/section:associations 映射:
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']