How to get the current URL in Codeigniter? – onlinecode
In this post we will give you information about How to get the current URL in Codeigniter? – onlinecode. Hear we will give you detail about How to get the current URL in Codeigniter? – onlinecodeAnd how to use it also give you demo for it if it is necessary.
In this article, we will explain to you how to get the current URL in Codeigniter. we can easily get the current Url using the Codeigniter helper URL. so first we have to load the helper URL after then we can get the URL. so you can see below the following example.
Get Current Urlwe will get current URL using the current_url() method.
$this->load->helper('url'); $page_url=current_url(); echo $page_url;
Get Segments Urlwe will get Segments URL using the segment URI.
$this->load->helper('url'); echo $this->uri->segment(1); echo $this->uri->segment(2);
Get Current Controller Namewe will get the controller name using the fetch_class() method.
$this->load->helper('url'); echo $this->router->fetch_class(); //It will returns controller name
Get Current Controller Method Namewe will get the current controller method’s name using the fetch_method() method.
$this->load->helper('url'); echo $this->router->fetch_method(); //It will return current method name
Hope this code and post will helped you for implement How to get the current URL in Codeigniter? – onlinecode. 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