dongre8505 2016-10-14 17:02
浏览 93
已采纳

如何在路由中使用通配符重定向

How to redirect with a variable in the route:

$id = 8;
return redirect('/userpage/{$id}');

The route:

Route::get('/userpage/{id}', 'UserController@userpage');

The controller:

public function userpage($id)
{
    return $id;        
}

This displays {$id}.

  • 写回答

1条回答 默认 最新

  • dongzituo5530 2016-10-14 18:19
    关注

    Just append the id to the url.

    return redirect('/userpage/' . $id);
    

    Or using double quoted strings

    return redirect("/userpage/{$id}");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?