When you need to use the base_url();
or config_item('base_url')
or $this->config->item('base_url')
First example:
public function __construct() {
parent::__construct();
$this->load->helper('url');
}
Or
public function index() {
$this->load->helper('url');
}
Second Example:
Go to application / config / autoload.php
And add the url to here which I think is best for you.
$autoload['helper'] = array(
'url',
'file',
'form',
'text',
'html',
'date'
);
Now go to the application / config / config.php Find $config['base_url'] = '';
Enter your base url example http://www.example.com/
or http://localhost/project/
$config['base_url'] = 'http://www.example.com/';
Recommended include forward slash at end
$config['base_url'] = 'http://localhost/project/';
Recommended include forward slash at end
If you need to remove the index.php find htaccess examples here
Download htaccess for codeigniter Git hub
Codeigniter User Guides
Codeigniter User Guides For Version 2 & 3 Can Be Found Here
Once all that is done
<li><a href="<?php echo base_url(); ?>">Home</a></li>
This will get you to the default home page