If you're trying to capture the output from an included 3rd party script you don't seem to be capturing everything, the following might help:
function ob_end_clean_all()
{
$s = "";
do
{
$s = ob_get_contents() . $s;
} while(ob_end_clean());
return $s;
}
This function closes all nested output bufferings, therefore closing any buffers that the included script does not explicitly close. It's basically a ob_end_clean that sweeps together all the output buffers instead of just the innermost one.
ob_get_clean
(PHP 4 >= 4.3.0, PHP 5)
ob_get_clean — Get current buffer contents and delete current output buffer
Description
string ob_get_clean
( void
)
Gets the current buffer contents and delete current output buffer.
ob_get_clean() essentially executes both ob_get_contents() and ob_end_clean().
Return Values
Returns the contents of the output buffer and end output buffering. If output buffering isn't active then FALSE is returned.
Examples
Example #1 A simple ob_get_clean() example
<?php
ob_start();
echo "Hello World";
$out = ob_get_clean();
$out = strtolower($out);
var_dump($out);
?>
The above example will output:
string(11) "hello world"
ob_get_clean
egbert teeselink
02-Feb-2008 03:47
02-Feb-2008 03:47
ludvig dot ericson at gmail dot com
10-Aug-2005 03:10
10-Aug-2005 03:10
Notice that the function beneath does not catch errors, so throw in an @ before those ob_* calls
webmaster at ragnarokonline dot de
02-Oct-2003 01:21
02-Oct-2003 01:21
Running PHP4 < 4.3.0, you can simply add the following to use the function anyway:
<?php
if (!function_exists("ob_get_clean")) {
function ob_get_clean() {
$ob_contents = ob_get_contents();
ob_end_clean();
return $ob_contents;
}
}
?>
