Using the Zend Framework, I wanted to send a file.
But when doing so from my controller I noticed a LineFeed allready sent:
The following code:
$data = 'Let me test this';
header('Content-Type: text/plain');
header('Content-Disposition: attachment; filename="output.txt";' );
//header('Content-Length: '.strlen($data));
ob_clean(); flush();
die($data);
Will give me the output.txt file:
[LF]
Let me test this
I have a preDispatch plugin, but I tried with the test code before exiting it, and the LF wasn’t outputted yet. And all controller-files starts with <?php. without any LF first.
So, my question is:
- What happens between preDispatch plugins are run and the controller is dispatched?
.. or even better: How can I find out where the LineFeed is outputted?
I have tested your code with an empty
preDispatch()method in aZend_Controller_Plugin_Abstractderived plugin, and I don’t get any LF in the output. I do get it, however, if I addecho "\n"explicitly into thepreDispatch()method body.So, chances are that your plugin is outputting the LF somewhere else. Maybe you are using a closing tag in your plugin? (just to discard possibilities).
(in the Zend Framework Coding Standard)