LoginSignup
1
1

More than 5 years have passed since last update.

laravel form param vs query string vs route param

Posted at

laravelにはparameter取得用のmethodが豊富ですが、役割のバラバラなんで、注意が必要。
http://xx.com/66?id=88http://xx.com/66で確認すれば直ぐわかるはず。
特にrequest()->idは強過ぎ! 怖い:smiling_imp:

Route::get('/{id}', function ($id) {
    echo request("id"). "<br>";
    echo request()->id . "<br>";
    echo \Request::input("id"). "<br>";
    echo \Request::query("id"). "<br>";
    echo \Request::route()->parameter("id"). "<br>";
    echo \Request::route("id"). "<br>";
    echo $id . "<br>";
});
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1