仅以小写形式获得param值 - PHP phalcon

问题描述 投票:0回答:1

我在URL中传递一些参数如下:

sample/team/highestScore/1

我接受此URL的路由器代码是:

$this->add('/sample/team/{tab:[a-zA-Z0-9-_]+}/{matchType:[0-9]+}',array('action' => 'teamAction'))->setName('sample');

但是在控制器中我将param'tab'的值变为highestscore,意思是小写。我需要param值作为最高分数。如何在没有大小写转换的情况下获取值。

请指教。提前致谢。

php phalcon
1个回答
0
投票

Controller: (app/controllers/someController.php)

function teamAction($tab = null, $matchType = null)
{
    exit(var_dump([
        $tab,
        $matchType
    ]));
}

route ( app/config/router.php )


$router = $di->getRouter();

$router->add(
    '/sample/team/{tab:[a-zA-Z0-9-_]+}/{matchType:[0-9]+}',
    [
        'controller' => 'some',
        'action'     => 'team'
    ]
);

$router->handle();

测试网址phalcon_path/sample/team/highestScore/1

array (size=2)
  0 => string 'highestScore' (length=12)
  1 => string '1' (length=1)
© www.soinside.com 2019 - 2024. All rights reserved.