Fatal error: function call undefined site_url ()

I am using the CodeIgniter framework for PHP. I created a view called "login.php". As soon as i

created a view, then I loaded the view inside a function called "index", which is located

inside a class called "CCI" that extends the controller, but I keep getting this error: Fatal

Error: calling the undefined site_url () function in C: \ wamp \ www \ FinalP_CCI_Clone \ system

\ application \ views \ login.php on line 12. I do not understand what I have, because

The welcome page loads fine, and my second function inside the CCI class also loads.

Here are some of the code:

Controller Files:

function CCI() { parent::Controller(); } function index() { $this->load->view('login'); } function test() { echo "Testing Data"; } 

}

/ * End of login.php file / / Location :./system/application/controllers/cci.php * /

class Welcome extends Controller {

 function Welcome() { parent::Controller(); } function index() { $this->load->view('welcome_message'); } function test() { echo "Testing Data"; } 

}

/ * End of welcome.php file / / Location :./system/application/controllers/welcome.php * /

+6
function php codeigniter view controller
source share
2 answers

You need to download the assistant. The site_url() function is provided by the url helper, as described here .

 $this->load->helper('url'); 
+33
source share

You can try the following:

  • First load the URL helper using:

    • $this->load->helper('url'); or set the following value in application/config/autoload.php
    • $autoload['helper'] = array('url');
  • Then you can show the site url:

Note. Results depend on values ​​stored in application/config/config.php

+1
source share

All Articles