What are the limitations of PHP in terms of deleting or stopping previously sent output?

When output has already been sent to the browser in PHP, it becomes difficult to delete or stop that output. One common solution is to use output buffering to capture the output before it is sent to the browser and then manipulate it as needed. This allows you to modify or delete previously sent output before it reaches the browser.

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

// Output sent to the browser
echo "Hello World!";

// Capture the output
$output = ob_get_clean();

// Manipulate the output
$output = str_replace("Hello", "Goodbye", $output);

// Send the modified output to the browser
echo $output;
?>