How To Get Current URL With Parameters Laravel 8


In this tutorial, today we discuss how to get current URL in laravel 8. we can using the URL generator the URL helper class and also use the facade class and request for laravel 8 get the URL. 

This discusses how to get current URL with parameters in laravel 8 echo definition. so how to get URL in PHP. We will learn how to get a URL in an easy way in the Laravel Framework.

How To Get Current Url In Laravel 8 ? | How To Get Url In PHP
Example:

Get the current URL without the query string

$currentURL = url()->current();
dd($currentURL);


Get the current URL including the query string

$currentURL = url()->full();
dd($currentURL);


Get the full URL for the previous request

$preURL = url()->previous();
dd($preURL);

Get the current URL Without Query String

$currentURL = $request->url();
dd($currentURL);


Get the current URL With Query String

$currentURL = $request->fullUrl();
dd($currentURL);


Get Only Parameters Using segment

http://www.example.com/one/two?key=value
$currentURL = $request->segment(3);
dd($currentURL);

I hope it can help you...

Leave a Reply

Your privacy will not be published. Required fields are marked *

We'll share your Website Only Trusted.!!

close