rur2641 rur2641 - 7 days ago 4x
PHP Question

How to redirect with wildcard in route

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}");