[thelist] PHP output buffering

Joel Konkle-Parker jjk3 at msstate.edu
Wed Aug 20 15:29:11 CDT 2003


First of all, thanks to everyone who have been helping me through this PHP
learning curve, you've been a big help.

I've decided to scrap file_get_contents in favor of output buffering
(ob_start(), ob_get_contents(), ob_end_clean()).

I've taken a working script that prints my template and added a buffered include
statement that takes the output from another script and inserts it into $output.
I dn't do anything with $output yet, I just leave it there.

Here's a snippet:

--
ob_start();
include "/directory/directory/index.original.php";
$output = ob_get_contents();
ob_end_clean();

function body() {


}

require "/hsphere/local/home/ballsome/template.php";
--

I put the output from index.original.php into $output, don't do anything with it
in body(), and print template.php.

The resulting output is perfect... if I wanted the output of index.original.php
(a forum package, if you were wondering). I get the exact same result as if I
called it directly in my browser, and no trace whatsoever of my template.

To test, I can comment out the ob_start() block, and the result is simply
template.php, a nicely-formatted webpage with no useful content.

If I've been reading the ob_* documentation correctly, this simply shouldn't
happen.... 

I've attached my actual script, and the URL in question is:
http://mod.ballsome.com/forum/index.php


--
Joel Konkle-Parker
Webmaster [Ballsome.com]

Phone     [662-518-1636]
E-mail    [jjk3 at msstate.edu]


More information about the thelist mailing list