Hi, I am getting the following error when trying to use $base_url in a view:
Message: Undefined variable: base_url
Filename: templates/header.php
Message: Function name must be a string
Filename: templates/header.php
From researching this, the most common reason for this is that the 'url' helper has not been loaded but I have added it to autoload.php
/application/config/autoload.php:
PHP Code:
$autoload['helper'] = array('url');
I have also checked the $base_url variable in config.php:
PHP Code:
$config['base_url'] = 'http://somedomain.com/folder/'; <--domain name changed from original
And this is the php of the view:
PHP Code:
<link href="<?php echo $base_url(); ?>css/bootstrap.min.css" rel="stylesheet">
This is how the view is been loaded from the controller:
PHP Code:
function index()
{
$data['tasks'] = $this->Task_model->get_all_tasks();
$this->load->view('templates/header');
$this->load->view('task/index',$data);
$this->load->view('templates/footer');
}
If I changed it to use a local variable it works fine:
PHP Code:
<?php $test = "http://somedomain.com/folder/" ?>
<link href="<?php echo $test; ?>css/bootstrap.min.css" rel="stylesheet">
I am new to this so it could be something simple but it is although the config file and/or autoload file is not linked in properly, corrupt or been overidden somehow. Any suggestions welcome.