Get Current Page URL in Codeigniter
Codeigniter provides a simple function to get the current page URL in a Codeigniter project easily. By using this function we can get the path to the current page to a variable or we can print the URL.
How to get the Current Page URL in Codeigniter?
To get the current page URL you need to load the URL helper class in your Codeigniter project first.
Step 1: Loading URL Helper Class
Loading URL helper class using the autoload:
Using the below code piece you can load the URL helper class automatically in every Controller.
$autoload['helper'] = array('url');
Or Loading URL helper class in controller class:
$this->load->helper('url');
Step 2: Get the current page URL
$current_page_url = current_url();
echo $current_page_url;