CodeIgniter Forums
$this->load->model( adding 2 unwanted line breaks in any view/echo - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: $this->load->model( adding 2 unwanted line breaks in any view/echo (/showthread.php?tid=26723)



$this->load->model( adding 2 unwanted line breaks in any view/echo - El Forum - 01-21-2010

[eluser]daniel9201[/eluser]
I tried this on codeigniter 1.7.2, apache 2.2 on windows vista and windows xp.


I have a simple xml webservice i am developing being consumed by a Flex datagrid component.

I want to echo out a simple xml string

in my Controller, function testflex
Code:
$xml = '';
        $xml .= "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
        $xml .=    "<entries>";
        

        $xml .=    "</entries>";
the above works fine, echos out fine

now i want to add data in.

Code:
// this is the new line that causes the output to add 2 line breaks at the start
$this->load->model('data_model');

        $xml = '';
        $xml .= "&lt;?xml version=\"1.0\" encoding=\"iso-8859-1\"?&gt;\n";
        $xml .=    "<entries>";
        
        $xml .=    "</entries>";

output now has 2 extra line breaks at the start that i don't want and they do cause an xml error for the consuming component.

See attached screen shots for the view of the source outputed to a browser.


$this->load->model( adding 2 unwanted line breaks in any view/echo - El Forum - 01-21-2010

[eluser]danmontgomery[/eluser]
You most likely have an extra line after the closing php tag in your data_model file


$this->load->model( adding 2 unwanted line breaks in any view/echo - El Forum - 01-22-2010

[eluser]daniel9201[/eluser]
problem is now fixed, i got rid of the closing [code]?&gt; [code] tag as per the style guide in my model code and it solved my problem.

There were no extra lines in my model code after the [code]?&gt; [code] so i still have no idea why that problem was occurring in the first place.

I now have my Flex datagrid being populated by a codeigniter controller function :-)

Thanks for your help.


$this->load->model( adding 2 unwanted line breaks in any view/echo - El Forum - 03-10-2012

[eluser]Unknown[/eluser]
hi
I have the same problem. but eliminating ?&gt; didn't help. I have no idea why $this->load->model cause an extra break line in view?




$this->load->model( adding 2 unwanted line breaks in any view/echo - El Forum - 03-10-2012

[eluser]CroNiX[/eluser]
Check for whitespace before your opening php tag.