• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CodeIgniter.php inserting newline

I love CodeIgniter, and use it for all of my projects.

A strange problem started happening, seemingly out of the blue. A newline is being inserted in the output, which breaks some pages and all programmatically generated images on my site.

I narrowed down the issue to line 288 of system\core\CodeIgniter.php, which simply reads:

$CI = new $class();

If I put an exit('blah') just before this line, it prints "blah" as expected. When placed just after this line, it prints "blah" after a newline. I'm not sure what that piece of code does next so don't know where else to look. This changed while I was developing new features on my site, but I can't think of why this would have anything to do with my most recent changes.

Please help! I'm confounded. Thanks!

Before that line insert
You have to see the class name.

Find the controller file that is correspondent to the class name. Preview its source, especially the constructor (if there is any) to find the spot that inserts the empty line.

If the things are not obvious, continue within the controller source with your trick 'blah'.

Thanks ivantcholakov. When I do that, it just returns my controller name, and this happens with any controller.

Inside the controller, the when I put the "blah" after "parent::__construct()", I get the strange newline. This is before any of my own site-specific code. So I think this has something to do with the parent constructor but I don't know where to find this.

Ah ha! I read a bit more about what the parent constructor does and realized that this calls the autoload models at this point (among many other things). Sure enough, a newline snuck into the beginning of one of my autoloaded model scripts. Must have been a typo while editing. Careful with your newlines! :cheese:

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.