【发布时间】:2015-07-09 22:56:21
【问题描述】:
我正在尝试使用 slim 的路由组,但我无法获取 url 参数以传递任何内容。
$app->group('/contest/:id', function($id) use ($API){
error_log('THIS IS THE CONTEST ID: '.$id); // id is blank... why?
$API->authorize('contest', $id);
$contest = new Contest($id);
$app->get('', function() use ($contest, $API){
$data = $contest->getSettings();
$API->output($data);
});
$app->get('/settings', function() use ($contest, $API){
$data = $contest->getSettings();
$API->output($data);
});
$app->get('/stats', function() use ($contest, $API){
$data = $contest->getStats();
$API->output($data);
});
$app->get('/fields', function() use ($contest, $API){
$data = $contest->getFields();
$API->output($data);
});
});
为什么我不能在回调函数中访问$id?这不是路线组的重点吗?
【问题讨论】: