ob_start() as saying "Start remembering everything that would normally be outputted, but don't quite do anything with it yet."
echo("Hello there!"); //would normally get printed to the screen/output to browser
$output = ob_get_contents();
There are two other functions you typically pair it with:
ob_get_contents(), which basically gives you whatever has been "saved" to the buffer since it was turned on with
ob_start(), and then
ob_flush(), which either stops saving things and discards whatever was saved, or stops saving and outputs it all at once, respectively.
- answered 2 years ago
- Community wiki