Friday, June 03, 2005

PHP: ob_flush_out()

Simple function to make buffer handling in PHP a little more user-friendly (just a little):

/* Fx ob_flush_out()
******************************/
function ob_flush_out($catch_buffer=FALSE, $reopen_buffer=FALSE) {

// buffer check
$ob_active = ob_get_length() !== FALSE;

if ( !$ob_active ) {
return FALSE;
}

// catch buffer
if ( $catch_buffer ) {

$buffer = '';
while ( $buffer .= @ob_get_flush() );

// flush buffer
} else {

while ( @ob_end_flush() );
$buffer = TRUE;

}

// reopen buffer?
if ( $reopen_buffer ) {

ob_start();

}

return $buffer;

} # end Fx
/*****************************/

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home