CodeIgniter Forums

Full Version: base_url() -> empty
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]sl3dg3hamm3r[/eluser]
Hey there

I'm just trying to do my first simple project with code-igniter. Well, with every framework, at the beginning there is more pain than joy, but I'm positive this gonna change soon.

Here my problem (code in controller):

Code:
$this->load->helper('url');
        echo "base-url: " . base_url();

and in the config-file, on line 14, I certainly defined the variable:
Code:
$config['base_URL'] = "http://127.0.0.1/xyz/";

But I don't get any url, it would only show 'base-url:' in the browser. What could that be?

Oh, and right another question: since I expect to use the url-helper almost everywhere, is there a load-routin which is called for every called controller? So I might need to write it only once...

Sincerely
Oliver

El Forum

[eluser]andreagam[/eluser]
Oliver, I can answer to your second question...
just open the autoload.php file in the config folder and on line 54 write
Code:
$autoload['helper'] = array( 'url');
you can autoload helpers and libraries that you largely use in your application.
I can't see anything wrong in your base_url() code, may be some other config is missing...

El Forum

[eluser]Yash[/eluser]
For first Qs

first autoload url helper

In view file use this

Code:
echo "base-url: " . base_url();

and in the config-file, on line 14, I certainly defined the variable:
Code:
$config['base_url'] = "http://127.0.0.1/xyz/";  //notice change here...case sensitive now try it.

Still there is error show me your code

El Forum

[eluser]sl3dg3hamm3r[/eluser]
Thank you guys, you helped me both!

Have a nice day!