|
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
Navigation:
[Reply to this message]
|