ob_end_clean()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

ob_end_clean()

Post by Gen-ik »

I think this does what it's ment to but could someone please confirm that this will in fact clear the buffer before the page is echo'd to the browser.

Code: Select all

ob_start();

function DoBuffer()
{
    $buffer = ob_get_contents();
    ob_end_clean();

    // Do some stuff with the buffer contents

    echo $buffer;
}

DoBuffer();
I know this could be done using ob_start("DoBuffer") but it's only an example... I'm using the buffer stuff within a class.
evilMind
Forum Contributor
Posts: 145
Joined: Fri Sep 19, 2003 10:09 am
Location: Earth

Post by evilMind »

Test using something like:

Code: Select all

$foo = ob_get_contents();
if ( ob_end_clean() ) {
   echo ($fooAgain = ob_get_contents() ? 'Buffer Not clean' : ' Buffer is clean');
}
bool ob_end_clean ( void )
Post Reply