ob_get_flush in PHP

ob_get_flush — Flush the output buffer, return it as a string and turn off output buffering

ob_get_flush(): string|false

ob_get_flush() flushes the output buffer, return it as a string and turns off output buffering.

Example of ob_get_flush

<?php
//using output_buffering=On
print_r(ob_list_handlers());

//save buffer in a file
$buffer = ob_get_flush();
file_put_contents('buffer.txt', $buffer);

print_r(ob_list_handlers());
?>

Leave a Comment