0
在這種情況下,如何獲取參數?獲取路由參數 - Slim Framework 3
$this->get('/{id}', function($request, $response, $args) {
return $response->withJson($this->get('singleSelect'));
});
$this->appContainer['singleSelect'] = function ($id) {
return $this->singleSelect($id);
};
public function singleSelect($id) {
return $id;
}
在此先感謝。
UPDATE
解決方案在我的情況:
$app->group('/id', function() {
$this->get('/{id}', function($request, $response, $args) {
$this['container'] = $args; //work with $args inside the container
return $this->singleSelect($id);
});
});
上面的另一個解決方案是在我的問題更新中。謝謝。 –