【发布时间】:2016-03-02 13:47:30
【问题描述】:
我想像这样在 Slim Framework v3.2.0 中使用子路由:
- www.test.com/
- www.test.com/foodtype/
- www.test.com/foodtype/page/
据我了解,只能调用一次 get 。目前我的 routes.php 中有这个:
$app->get('/', function () {
// Load index page
});
$app->get('/{foodtype}', function ($request, $response, $args) {
// Load page based on the value of $args['foodtype']
});
如何为 page1 添加单独的可选路由?
我试过了:
$app->get('/{foodtype}/{page}', function ($request, $response, $args) {
// Load page based on the value of $args['foodtype'] and $args['page']
});
这会导致“找不到页面”错误。我想我也需要转义可选的“/”?
【问题讨论】: