Jump to content

[SOLVED] output buffering - bufferes include data bu not initial data


PC Nerd

Recommended Posts

Hi,

 

Code:

<?php
$OUTPUT = array();
$PAGE_LEVEL = 1;
$_USER['doc_root'] = '../';

ob_start();

###
### Main page output, start template buffering
###

echo "Content part 1<br>";
echo "Content part 2<br>";
echo "Content part 2<br>";

$OUTOUT['CONTENT'] = ob_get_contents();
#$OUTPUT['CONTENT'] = "TESTING!!!";
#ob_get_flush();
ob_clean();

#ob_start();
require("../themes/template.php");
$OUTPUT['template'] = ob_get_contents();
ob_clean();
#ob_start();
require("../pre/crumbs.php");
$OUTPUT['CRUMBS'] = ob_get_contents();
ob_clean();

#echo $OUTPUT['template']."<br>";
#echo $OUTPUT['CRUMBS']."<br>";

$OUT = "";
#$OUT .= $OUTPUT['CRUMBS'];
#$OUT .= "<br>".$OUTPUT['template'];
$OUT .= "<br>".$OUTPUT['CONTENT'];

/*
#$OUT .= str_replace("[%CONTENT%]", $OUTPUT['CONTENT'], $OUTPUT['template']);
#$OUT .= str_replace("[%CRUMBS%]", $OUTPUT['CRUMBS'], $OUTPUT['template']);
*/

echo $OUT;
?>


$OUTPUT['CONTENT'] isnt set - and doesnt display.  eventually( as you can see from the commented out areas), Ill bs using the include files to replace content in a templat.... hence $OUTPUT['template']

Am I using the wrong function, or is there somethign else ive missed?

thanks

Link to comment
Share on other sites

but if ive stored the output as a variable as i have done.. ( in the array)... it shouldnt really care whether its output to "echo" or otput to storage.

 

* Ive tried a range of functions:

 

ob_get_flush(); to get the contents, and that way i didnt have to clear the buffer and all sort of things.

 

also - i tried commenting out all of the ob_clean();'s, and placed a single one after the echo $OUT; but it made no difference.

 

Any other suggestions?

 

Thanks

Link to comment
Share on other sites

When you first assign something to $OUTPUT['CONTENT'] you've miss-spelt it. You have the following...

 

$OUTOUT['CONTENT'] = ob_get_contents();

 

When it should be...

 

$OUTPUT['CONTENT'] = ob_get_contents();

 

Also, just a thought, but upper case variables names look horrible.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.