How to get current url with query string in codeigniter?

Today now in this post i will show you How to get current url with query string in codeigniter? Sometimes we may need to get the current URL with parameters in our codeigniter project. Then we can get easily get this by using “url” helper. We know Codeigniter is provide us url helper library on that way we can get the existing page url or base url etc. We can also get only the parameters without URL by using “input” as like bellow.

$parameters = $this->input->get();

But, we are getting the full path by using “url” helper and $_SERVER variable. So, we can see here how to get the full path by using both as like as bellow:

Example:
$this->load->helper('url');
$currentURL = current_url();
$params   = $_SERVER['QUERY_STRING'];
$fullURL = $currentURL . '?' . $params;
print_r($fullURL);

Read Also: How to implement Google new reCAPTCHA Code in PHP?

Thanks for read. I hope it help you. For more you can follow us on facebook

Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.