kohana 像在 codeigniter 中一样获取参数

发布于 2024-12-11 13:53:27 字数 572 浏览 0 评论 0原文

搜索这个问题,我发现了这个问题/答案: Kohana 3 获取当前控制器/action/arguments

我最近切换到 Kohana使用 codeigniter 一段时间后。 在 Codeigniter 中,您可以(在控制器中)执行以下操作:

public function action_nameAction($param1, $param2 = null, ...){
$something = $param1;
}

通过调用 www.mysite.com/controllerName/param1/param2

我真的很喜欢这种方法,并且不太理解 Kohana 重新定义路线的方法的要点...

如果Kohana 中有一个使用 Codeigniter 方法的解决方案,我想要一些关于如何实现它的线索。 如果没有,请有人向我解释一下必须为不属于默认路由的每种情况重新定义新路由的好处......

searching for this question, I found this question/answer:
Kohana 3 get current controller/action/arguments

I recently switched to Kohana after using codeigniter for a while.
In Codeigniter, you could just do (in a Controller):

public function action_nameAction($param1, $param2 = null, ...){
$something = $param1;
}

by calling www.mysite.com/controllerName/param1/param2

I really liked this approach and don't really understand the point of Kohana's approach with redefining the routes...

If there is a solution to have the Codeigniter approach in Kohana, I would like some clues on how to implement it.
If not, please could someone explain me the interest of having to redefine new routes for every case that doesnt fall into the default route...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不即不离 2024-12-18 13:53:27
Route::set('default', '(<controller>(/<action>(/<id1>(/<id2>))))')
    ->defaults(array(
    'controller' => 'welcome',
    'action' => 'index',
));

$id = $request->param('id1');
$id = $request->param('id2');
Route::set('default', '(<controller>(/<action>(/<id1>(/<id2>))))')
    ->defaults(array(
    'controller' => 'welcome',
    'action' => 'index',
));

$id = $request->param('id1');
$id = $request->param('id2');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文