Welcome Guest, Not a member yet? Register   Sign In
base_url() stops executing

I have used the base_url() in a lot of view stuff already and it usually works. Lately though it has been giving me a problem.

My config.php reads:

$config['base_url'] = "http://www.someurl.com/somedir/";

Then I tried referencing a stylesheet like this:

<link rel="stylesheet" href="<?php echo base_url(); ?>css/style.css" type="text/css" media="screen" />

That actually kills the generation of the site like so:

<link rel="stylesheet" href="

When I then echo base_url() anywhere it stops when it gets to that point.

Something is fishy and I don't know what. I have had it work on this host before. I can also load the CSS in the example if I just create the url myself instead of using base_url(), but that would be quite sloppy.

humm base_url is a pretty simple function.. have you autoloaded the helper?

$autoload['helper'] = array('url');

So when did it last work and what did you do before you noticed it stopped working?

base_url return config->slash_item which can return false if the item doesn't exist in the config array for some reason, so test to see if this is a case

if(base_url() === FALSE) {
  echo 'Something is seriously wrong';
} else {
  echo 'Hmm... I'm confused';

How very odd, I am pretty sure I have never needed to load the helper to get it to work. Can't argue with the code though. Mabye in another project it was already in the autoload, odd indeed.

It's stuff like this that a quick glance from someone else can easily fix. It was indeed the helper that needed autoloading. Simple thing, it is indeed monday morning.

Oh, I assumed you had it working on this project, and I assumed you wouldn't have un autoloaded it to break it lol

ignore, reply.. i was waffling.. anyway glad it works.

@Dam1an: I had it working on this application. I just dug into the code and it seems I manually loaded the url helper for a certain function then during development somehow removed it.

Theme © iAndrew 2016 - Forum software by © MyBB