1

我想路由这样的东西: http ://myapp.com/mycontroller/...?x= ...

mycontroller 之后的所有内容都是未知的。我不知道路径,也不知道任何参数。路由后,路径和参数应显示为一个变量。

// route in routes.php
Router::connect('/mycontroller/*', 'Mycontroller::index');

// the index function of Mycontroller class
public function index($pathWithParameters) {
    print_r($pathWithParameters); // something like: 'hello/world?name=mewel&id=123
}

这可能吗?

4

1 回答 1

6
Router::connect('/mycontroller/{:args}', 'Mycontroller::index');

然后,从您的控制器中,检查$this->request->params$this->request->query

注意:您也可以func_get_args()在控制器中使用。以默认 PagesController 为例

于 2012-02-24T01:55:17.263 回答