9

I am using the CodeIgniter framework for PHP. I have created a view named "login.php". Once I

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

inside a class named "CCI" that extends the Controller but I keep receiving this error: Fatal

error: Call to undefined function site_url() in C:\wamp\www\FinalP_CCI_Clone\system

\application\views\login.php on line 12. I don't understand the issue I an having because the

welcome page loads fine and my second function inside of the "CCI" class loads fine as well.

Here is some of the code:

Controller Files:

function CCI()
{
    parent::Controller();
}

function index()
{
    $this->load->view('login');
}

function test()
{
    echo "Testing Data";
}

}

/* End of file login.php / / 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 file welcome.php / / Location: ./system/application/controllers/welcome.php */

1
  • 1
    Post more of your code, we can only guess what it could be at this point... Commented Dec 1, 2010 at 3:15

2 Answers 2

38

You have to load the helper. The function site_url() is provided by the url helper, as described here.

$this->load->helper('url');
Sign up to request clarification or add additional context in comments.

1 Comment

Thank You. Your help is really appreciated. Loading the helper function solved the issue.
5

You can try this:

  1. First Load the URL Helper with:

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

Note: Results depends on values stored in application/config/config.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.