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

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}.

Just append the id to the url.

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

Or using double quoted strings

return redirect("/userpage/{$id}");