Laravel get current url
Laravel get current url : If you are working with laravel you often need to get current url and its parameters. You can use helper function URL::current(); to get the current url in laravel4, laravel5. Here we are going to demonstrate the method to get current url and how to get its parameter.
Laravel get current url Syntax
Here is simple syntax to get current url in laravel.
Laravel get current url Syntax
Route::get('/current/url', function() { return URL::current(); }); |
Laravel get url parameters
Here is simple syntax to get url parameters in laravel. Suppose you have following url www.xyz.com/home/user?page=2. Suppose you need to get the page value that is 2.
Laravel get current url Syntax
$segment = Request::segment(3); |
Which will give the page string’s value from url.
Advertisements