PHP ob_clean() Function
The PHP ob_clean() function deletes the contents of the output buffer. This function does not destroy the output buffer like ob_end_clean() does.
Note: The output buffer must be started by ob_start() with PHP_OUTPUT_HANDLER_CLEANABLE flag. Otherwise this function will not work.
Syntax
ob_clean()
Parameters
No parameter is required.
Return Value
Returns true on success or false on failure.
Example: ob_clean() example
The example below shows the usage of ob_clean() function.
<?php //turn on the output buffering ob_start(); echo "This content will be cleaned from the output buffer."; //clearing the output buffer ob_clean(); echo "New content is added to the output buffer."; //flushing the output buffer and //turning off the output buffering ob_end_flush(); ?>
The output of the above code will be:
New content is added to the output buffer.
❮ PHP Output Control Reference