PHP: ob_clean - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

ob_end_clean flush

Last updated: Fri, 26 Jan 2007

view this page in

# ob_clean

(PHP 4 >= 4.2.0, PHP 5)

ob_clean -- Clean (erase) the output buffer

## Description

void ob_clean ( void )

This function discards the contents of the output buffer.

This function does not destroy the output buffer like ob_end_clean() does.

See also ob_flush(), ob_end_flush() and ob_end_clean().

add a note User Contributed Notes
ob_clean
cipri at php dot net
29-Jun-2004 09:54
`In Re: to Anonymous at 14-Jan-2003.
You can't mimic the behaviour 100% by using that combination of function calls(ob_end_clean() && ob_start()), since outputhandlers may be defined already by the initial ob_start, which may not work as expected when called twice.`
kouber at php dot net
11-May-2004 05:05
`Although it is mentioned in the manual, you have to be careful when using output buffering in big cycles (such as mass mail sending scripts), because ob_clean() actually does not free any memory, and with each iteration the amount of memory allocated from your script will increase significantly. Instead of calling ob_clean() at the end of the cycle, you have to either use ob_get_clean(), which is a combination of ob_get_contents() and ob_end_clean(), or just ob_end_clean() to free the memory. Try the following test to see the difference:
<?php
for ($i=0; $i<10; $i++) {
ob_start();
echo "This is iteration $i: ";
// * Don't do this!
// $buf = ob_get_contents();
// ob_clean();
// * Use this instead:
$buf = ob_get_clean();
echo $buf;
echo memory_get_usage()."\n";
}
?>`
14-Jan-2003 08:23
`As far as I can tell the only way to mimic ob_clean()'s behaviour on PHP < 4.2.0 is calling ob_end_clean() followed by ob_start().`
add a note
ob_end_clean flush

Last updated: Fri, 26 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 10:36:09 2007 PST