Codeigniter – How to get current url in controller or view ?
In this post we will give you information about Codeigniter – How to get current url in controller or view ?. Hear we will give you detail about Codeigniter – How to get current url in controller or view ?And how to use it also give you demo for it if it is necessary.
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);
Hope this code and post will helped you for implement Codeigniter – How to get current url in controller or view ?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs