Loading a PHP page progressively...
Moderator: General Moderators
It's kind of like putting newspaper over a pile of dog crap instead of cleaning it up... you may not see the problem any more but it's still there.
This is why the majority of experienced developers seperate applications into layers. You should be doing all of the application logic long before any output is sent... if you did, you wouldn't have to worry about the "headers already sent" problem at all...
Follow the link feyd posted... there's all kinds of info about this.
This is why the majority of experienced developers seperate applications into layers. You should be doing all of the application logic long before any output is sent... if you did, you wouldn't have to worry about the "headers already sent" problem at all...
Code: Select all
<?php
// All application logic goes here
$foo = santitize($_GET['input_var']);
$foo = do_some_stuff_to($foo);
// If we want to do a redirect, do it before output is send...
if($foo == false){
// No error here, since there hasn't been any output yet...
header('Location: http://www.someplace.com');
exit;
}
// OK, now that all of our logic is done... now we can send output...
echo $foo;
?>My problem is because I include the header layout of the script at the top, of the page... Like this:
Would I have to do it like this?
Thanks for your help.
Code: Select all
<?php
incluide("headertemplate.html");
if ($foo == false) {
header("location: blah.php");
} else {
echo "this is the text...";
}
incluide("footertemplate.html");
?>Code: Select all
<?php
if ($foo == false) {
header("location: blah.php");
} else {
$content = "this is the text...";
}
incluide("headertemplate.html");
echo $content;
incluide("footertemplate.html");
?>