AlanMorton2.0
AlanMorton2.0

Reputation: 1053

Call to undefined function anchor() in

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

Answers (6)

Shivam
Shivam

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

Abhishek Gurjar
Abhishek Gurjar

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

Jibin George
Jibin George

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

Nil&#39;z
Nil&#39;z

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

Gerardo Jaramillo
Gerardo Jaramillo

Reputation: 485

Make sure that your controlLer, has the parent statment in the construct

function __construct(){
     parent:: ControlLer();
}

Upvotes: 0

Eric
Eric

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

Related Questions