Reputation: 1053
Hi everyone I am new to a PHP
framework codeIgniter
, I am going over the user guide iv ran in to a problem, I am on the part where you load helper file but for some reason my code just in not working I keep getting this error:
Fatal error: Call to undefined function anchor() in /home/fresherd/public_html/CI/system/application/views/blogview.php on line 17
now im not 100% sure that it is loading the helper file this could be causing the but I am not sure how to detect the file has been loaded
any advice will help many thanks, Alan
Upvotes: 2
Views: 10252
Reputation: 101
Just add url in helper inside autoload.php inside config folder.
$autoload['helper'] = array('url');
or you can add this inside your function
$this->load->helper('url');
Upvotes: 4
Reputation: 7476
You can autoload your helper so you dont have to reload it on every page..
$autoload['helper'] = array('url');
or manually load it on every page..
$this->load->helper('url');
Upvotes: 0
Reputation: 41
loading the helper in the controller solved my problem,, jus try this way
<?php
function __construct(){
parent::__construct();
$this->load->helper('url');
}
?>
or try putting it in autoload array in config.php in the application/config folder., like
$this->load->helper('url');
hope it helps...
Upvotes: 2
Reputation: 7475
If you are not sure please check the autoload.php file in the config folder or in your controller put the following function:
<?php
function __construct(){
parent::__construct();
$this->load->helper('url');
}
?>
Upvotes: 5
Reputation: 485
Make sure that your controlLer, has the parent statment in the construct
function __construct(){
parent:: ControlLer();
}
Upvotes: 0
Reputation: 1197
Just load the helper in your controller or put it in the auto load array.
$this->load->helper('url');
I would also change Gerardo's code to this:
function _construct() {
parent::__construct();
}
Upvotes: 2