How to get current url with query string in codeigniter?

By Hardik Savani | August 29, 2016 | | 68491 Viewer | Category : Codeigniter


If you require to get current URL with parameters in your codeigniter project then you can get easily using "url" helper. Codeigniter provide url helper library that way we can get existing page url or base url etc. you can also get only parameters without URL using "input" as like bellow.

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

But, we are getting full path using "url" helper and $_SERVER variable. So, you can see how to get full path using both as bellow:

Example:

$this->load->helper('url');


$currentURL = current_url();

$params = $_SERVER['QUERY_STRING'];


$fullURL = $currentURL . '?' . $params;

print_r($fullURL);



Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.


We are Recommending you: