1

I config a router

'users/user(/fields=:fname,:lname,:age)?'   => 'users/user/$1/$2/$3',

used: /users/user/fields=John,Smith,33 (fname = John, lname = Smith, age = 33)

I want config like
users/user?fields=John,Smith,33

but I can't use "?" in a router.

4

1 回答 1

0

路由不包括 GET 参数,因为它们不被视为 URI 的一部分。对于您想要的功能,最好将闭包指定为路线的右侧并返回构造的字符串。

'users/user' => function(){ 
    return 'users/user/' //Custom logic goes here to build the internal URI
}
于 2014-10-08T15:10:17.973 回答