Laravel Request getting current path with query string

前端 未结 9 520
萌比男神i
萌比男神i 2020-12-23 13:20

Is there a Laravel way to get the current path of a Request with its query parameters?

For instance, for the URL:

http://www.example.com/one/two?key=         


        
9条回答
  •  无人及你
    2020-12-23 13:41

    Request class doesn't offer a method that would return exactly what you need. But you can easily get it by concatenating results of 2 other methods:

    echo (Request::getPathInfo() . (Request::getQueryString() ? ('?' . Request::getQueryString()) : '');
    

提交回复
热议问题