How can output buffering be used to store the output of a PHP file in a variable?

Output buffering in PHP can be used to capture the output of a PHP file and store it in a variable instead of immediately sending it to the browser. This can be useful in situations where you need to manipulate or process the output before displaying it. By using output buffering functions like ob_start() and ob_get_clean(), you can easily achieve this functionality.

<?php
ob_start(); // Start output buffering

// Your PHP code here

$output = ob_get_clean(); // Store the output in a variable

echo $output; // Output the stored content
?>