Reply to Re: Warning: Cannot modify header information - headers already sent my (output started at ...

Your name:

Reply:


Posted by J.O. Aho on 10/03/04 11:33

Ian Rutgers wrote:
> I am creating a page that will display thumbnails of images in a folder. I
> can read the images in the folder but when I try to use the <?
> header("Content-type: image/jpeg");?> ... I get the error message as
> detailed in the subject line.
>
> From what I've researched, it has to do with whitespace on that line ... but
> I don't see any ... help!!!

If you include files, eg

<?PHP
include('file1');
include('file2');
header("Content-type: image/jpeg");
....
?>


Then if there is a whitespace in file1 or in file2, will cause that the
header() comes after the whitespace has been sent. You must look at files that
may be included in the files you have included (file1 and file2), as those do
affect things too.

Don't forget to only look at the top of the file, but at the end of the file
too and of course in between sections where you may break the php.


A method that can lessen the problem with white spaces and such, is to use
ob_start() and ob_end_flush(), then you have only one file to look for white
spaces and such, and ti's the main file.

http://www.php.net/manual/en/function.ob-start.php
http://www.php.net/manual/en/function.ob-end-flush.php



//Aho

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация