CodeIgniter Forums
Novice question about Output class - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Novice question about Output class (/thread-5687.html)



Novice question about Output class - El Forum - 01-31-2008

[eluser]Unknown[/eluser]
Hi,

I am a novice in CI and i have questions about some solutions, the first is:

I have a function like this in my controller:

Code:
function testAjax()
{
    $this->output->set_header('Content-type: text/xml');
    $this->output->set_output('&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt;<root>content</root>';
}

but i know i can do somethink like that:
Code:
function testAjax()
{
    header('Content-type: text/xml');
    echo '&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt;<root>content</root>';
}

the second solution use only php core functions.

Do you agree that the second solution is better (faster, portable)?
Is there any motive to use first solution?


Novice question about Output class - El Forum - 01-31-2008

[eluser]Pascal Kriete[/eluser]
I could see the first one as being more useful in an if statement, but to be honest I never use either feature. Output is what views are for.