Reply to Re: Headers already sent problem

Your name:

Reply:


Posted by J.O. Aho on 02/23/06 16:05

noone wrote:
> It seems that using sessions is a real pain, as i come across this "headers
> already sent "
> problem.
> Is there some way to solve this?

header() should always be before any output from a file

--- bad example 1 ---
<?PHP
echo "hello!!!<br>";
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
?>
--- end of example ---

this includes html code

--- bad example 2 ---
<html><head><title>MyPage</title>
<?PHP
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
?>
</head><body>
Hello!!!
</body></html>
--- end of example ---

and whitespaces in the beginning of a file

--- bad example 3 ---
<?PHP
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
echo "hello!!!<br>";
?>
--- end of example ---

If you use include functions, then the rule applies to the included file too.


//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

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