Fatal error: Call to undefined function base_url()
20,073
Solution 1
You need to load the URL helper
$this->load->helper('url');
Solution 2
You need to write
public function __construct() {
parent::__construct();
$this->load->helper('url');
}
In your controller and then use in your view
Author by
Ashley Stewart
Updated on August 11, 2020Comments
-
Ashley Stewart over 3 years
This line keeps giving me the aforementioned error:
<img style="padding:10px; margin:auto; display:block;" <?php echo 'src="' . base_url("assets/images/email/mailheader.jpg") . '"' ?>>
I'm running this on xampp and can't seem to figure it out, any help would be greatly appreciated.
-
Ashley Stewart about 10 years$autoload['helper'] = array('common_functions', 'form', 'url'); is already present in autoload.php
-
cornelb about 10 yearsCan you also include the code I added, at the beginning of the view?
-
Ashley Stewart about 10 yearsdoing so results in Fatal error: Using $this when not in object context
-
gurudeb about 10 yearsare you using it in a helper function? probably you have not extended the codeigniter controller... Use $CI = get_instance(); For older versions of php, use =& Then, use $CI wherever you would normally use $this