Please help with header problem, parallel output

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
flexy123
Forum Newbie
Posts: 3
Joined: Thu Dec 11, 2008 9:24 pm

Please help with header problem, parallel output

Post by flexy123 »

I cannot send header twice in a PHP file, and i also cant send a PHP header if there was already text output on the page.

So..how do i do it that i can eg. initiate a file-download, from a web-site or script?

(The file-download part is a little piece of 3rd party code which forces a download, it sets mine-types and HEADERS.
When the download initiates, the snippet send the headers and then prints the file)

Since this piece of code is ON a site/code where there already has been output...of course it comes up with
"cannot output since headers already sent"

Same problem eg with code which actually displays and streams a valid image with valid mime type and header.

I know there must be ways since web sites in PHP can very well display pictures. But if i build this code in another PHP i again have the problem i cant display the picture since the header is already sent by the content of the site!

there must be ways to have this output "parallel", and there must be ways to have eg a PHP program which can pop-up with a download window, sending content w/ valid headers from an existing site without telling me "headers already sent"..
Georg.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Please help with header problem, parallel output

Post by requinix »

Not quite sure what you're trying to do.

Just in case: you can't do an HTML page and an image at the same time.
anoopsn
Forum Newbie
Posts: 2
Joined: Fri Dec 12, 2008 12:55 am

Re: Please help with header problem, parallel output

Post by anoopsn »

Please try the following code,

<?php
ob_start();

// Add your page content here

ob_end_clean();
?>
Post Reply