CodeIgniter Forums
base_url() -> empty - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: base_url() -> empty (/thread-10460.html)



base_url() -> empty - El Forum - 07-31-2008

[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


base_url() -> empty - El Forum - 07-31-2008

[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...


base_url() -> empty - El Forum - 08-01-2008

[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


base_url() -> empty - El Forum - 08-01-2008

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

Have a nice day!