output buffering but content still escapes?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I call ob_start() at the top of the page. Later I include the page
template. I'd like to make some changes to stuff in that template before
it goes to the screen. I've commented out everything that might allow
content to reach the browser, and yet the page still renders as normal.
Why is that?


// 06-04-08 - from now on we will load various "front pages". We will
look in
// site_specific_files for files that start with "frontpage_"


$frontPage = $_GET["frontPage"];

if (!$frontPage) {
    $storedFrontPageFileName = $_COOKIE["storedFrontPageFileName"];
    if (!$storedFrontPageFileName) {
        $arrayOfAllFiles = array();
        if ($handle = opendir('site_specific_files')) {
        /* This is the correct way to loop over the directory. */
        while (false !== ($file = readdir($handle))) {
            if (substr($file, 0, 10) == "frontpage_") {
                $arrayOfAllFiles[] = $file;
        $whichVersionOfTheFrontPageShouldWeUse = rand(0,
count($arrayOfAllFiles) - 1);
        $storedFrontPageFileName =
        setcookie ("storedFrontPageFileName", $storedFrontPageFileName,
time() + 86000, "/");
} else {
    $storedFrontPageFileName = $frontPage;


// 06-05-08 - right here I should add the name of the front page
// to every link, so when people click on links, and we analyze
// the data in Google Analytics, we will be able to see which
// front page they were using.
//$stringToBeOutput = ob_get_contents();

$stringToBeOutput = str_replace(".php?", "xxxxxxx", $stringToBeOutput);
$stringToBeOutput = str_replace(".php", ".php?", $stringToBeOutput);
$stringToBeOutput = str_replace("xxxxxxx", ".php?", $stringToBeOutput);

//echo $stringToBeOutput;


Re: output buffering but content still escapes?

Lawrence Krubner wrote:
Quoted text here. Click to load it

Okay, sorry. I figured it out. Turns out you have to call ob_end_clean();

Quoted text here. Click to load it

Site Timeline