Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter.php inserting newline
#1

[eluser]darioism[/eluser]
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:

Code:
$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!
#2

[eluser]ivantcholakov[/eluser]
Before that line insert
Code:
var_dump($class);
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'.
#3

[eluser]darioism[/eluser]
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.
#4

[eluser]darioism[/eluser]
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:




Theme © iAndrew 2016 - Forum software by © MyBB