Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6543695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:22:37+00:00 2026-05-25T11:22:37+00:00

Using the Zend Framework, I wanted to send a file. But when doing so

  • 0

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?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:22:37+00:00Added an answer on May 25, 2026 at 11:22 am

    I have tested your code with an empty preDispatch() method in a Zend_Controller_Plugin_Abstract derived plugin, and I don’t get any LF in the output. I do get it, however, if I add echo "\n" explicitly into the preDispatch() 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).

    For files that contain only PHP code, the closing tag (“?>”) is never
    permitted. It is not required by PHP, and omitting it´ prevents the
    accidental injection of trailing white space into the response.

    (in the Zend Framework Coding Standard)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I set up a Zend Framework application using Zend_Tool, but I wanted multiple modules
I am using Zend Framework to send mail. It's doing something very odd, the
I'm using Zend framework, and most of the action controller that I have return
Note: I'm using Zend Framework, but I think most of this applies to PHP
I am using Zend Framework and 3rd party application written in php for file
I am using Zend Framework but not Zend_Application , just some classes - no
Hi i am using zend framework and doing one login example with database...i am
I'm using Zend-Framework 1.9.5 to make a web-application, But it's Url_Helper was quite tricky
I am using Zend Framework. I want to fetch record from database without considering
Using Zend Framework, I need to (1) read a record from a MySQL database,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.