Getting GET “?” variable in laravel

前端 未结 8 804
夕颜
夕颜 2020-12-16 08:41

Hello I\'m creating API using REST and Laravel following this article.

Everything works well as expected.

Now, I want to map GET request to recognise variabl

8条回答
  •  自闭症患者
    2020-12-16 09:40

    In laravel 5.3

    I want to show the get param in my view

    Step 1 : my route

    Route::get('my_route/{myvalue}', 'myController@myfunction');
    

    Step 2 : Write a function inside your controller

    public function myfunction($myvalue)
    {
        return view('get')->with('myvalue', $myvalue);
    }
    

    Now you're returning the parameter that you passed to the view

    Step 3 : Showing it in my View

    Inside my view you i can simply echo it by using

    {{ $myvalue }}
    

    So If you have this in your url

    http://127.0.0.1/yourproject/refral/this@that.com

    Then it will print this@that.com in you view file

    hope this helps someone.

提交回复
热议问题