Welcome Guest, Not a member yet? Register   Sign In
base_url() error
#1

[eluser]Matrices[/eluser]
Hey all,

I just installed code igniter on my server and I came across an error when building out my homepage. It seems that base_url() isn't defined. I've used CI before on other projects and didn't have this problem. Can anyone shed some light on the situation?
Code:
<?

class Blog extends Controller {

    function Blog()
    {
        parent::Controller();    
    }
    
    function index()
    {
        base_url();
    }
}

?>

creates: "Fatal error: Call to undefined function base_url() in /home/weirdmac/public_html/system/application/controllers/blog.php on line 12"
#2

[eluser]Ihab Khattab[/eluser]
I think you should first load url helper so you can use base_url()

Code:
<?

class Blog extends Controller {

    function Blog()
    {
        parent::Controller();    
    }
    
    function index()
    {
        $this->load->helper('url');
        base_url();
    }
}

?>

or you can autoload it "so you don't need to load it every time you want to use it" from
Quote:application/config/autoload.php
Code:
$autoload['helper'] = array('url');
#3

[eluser]Matrices[/eluser]
that did it! Thank you very much




Theme © iAndrew 2016 - Forum software by © MyBB