How to Get Current URL in Codeigniter?
Sometimes, we need to get current URL path in your controller file or view file. So, we can get simply using "url" helper. Codeigniter provide url helper library that way we can get existing page url or base url etc.
current_url() through we can get current url in your Codeigniter application. But, you should load "url" helper before use current_url(). you can load url helper as bellow:
$this->load->helper('url');
In bellow example, you can see code how can i get current url in your controller file. So, let's see.
$this->load->helper('url');
$currentURL = current_url();
print_r($currentURL);
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. 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, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- Codeigniter Dynamic Highcharts Example
- How to implement and use DataTables in CodeIgniter?
- Codeigniter Drag and Drop Multiple Image Upload Example
- How to Get Current Controller or Method Name in Codeigniter?
- Codeigniter Dynamic Dependent Dropdown using Ajax Example
- Codeigniter Ajax Infinite Scroll Pagination Example
- Codeigniter Image Upload with Validation Example
- Codeigniter Ajax CRUD Tutorial Example
- Codeigniter Select2 Ajax Autocomplete from Database Example
- How to Get Current URL with Query String in Codeigniter?
- How to Get Current URL in Laravel?
- How to Get IP Address in Codeigniter?
- How to Get a Current Page URL in PHP?
- Codeigniter 3 and AngularJS CRUD with Search and Pagination Example.