A lot of Magento tutorials are using echo to output controller text. However, using echo can cause weird problems, like the infamous “Headers already sent” error.
I understand that the right way to return response is by using
$this->getResponse()->setBody($text);, but for some cases I prefer using echo for convenience (returning by parts vs returning all at once).
So my question is - is there a "safe" Magento way to use echo in controllers? or is it a big no-no and should never be used?
PS I can use collect data myself and just call
setBody() at the end (eg do something like "
$ret .= ..." instead of echo), but in this case an uncaught error will not give me any output, while using
echo will at least show me some of the output, up until the error. I'm talking about debug pages here so partial is still very useful :)