ob_get_clean in PHP

ob_get_clean — Get current buffer contents and delete current output buffer

ob_get_clean(): string|false

Gets the current buffer contents and delete current output buffer

ob_get_clean() essentially executes both ob_get_contents() and ob_end_clean().

Example of ob_get_clean

<?php

ob_start();

echo "Hello World";

$out = ob_get_clean();
$out = strtolower($out);

var_dump($out);
?>

Output

string(11) "hello world"

Leave a Comment