Welcome Guest, Not a member yet? Register   Sign In
_output called, but $output is empty
#1

[eluser]Unknown[/eluser]
I have a method in my controller

Code:
function test() {
  print "test";
}

function _output($output) {
   var_dump($output);
}

_output() is being called, but $output is blank, and the output is sent, so that I see "test" first, then the var dump of an empty string.

I don't have caching on, no compression, no hooks, nothing I can see that would cause this. Any suggestions?

Thx,

Tac
#2

[eluser]oldmatt[/eluser]
I don't see in your question where you have defined
Code:
$output

I think I am missing something.
#3

[eluser]InsiteFX[/eluser]
Did you look at CodeIgniters Output Library?

InsiteFX
#4

[eluser]WanWizard[/eluser]
CodeIgniters Output library calls _output() in your controller if it exists, passing all buffered output to it:
Code:
if (method_exists($CI, '_output'))
{
    $CI->_output($output);
}
else
{
    echo $output;  // Send it to the browser!
}

The problem here is that direct output generated in the controller by things like echo, print, or var_dump are not buffered by the Output library, which is probably why $output is empty.




Theme © iAndrew 2016 - Forum software by © MyBB