What could be causing the "Warning: Cannot modify header information - headers already sent" error in PHP?

The "Warning: Cannot modify header information - headers already sent" error in PHP occurs when there is output (such as whitespace, HTML, or error messages) sent to the browser before the header() function is called. To solve this issue, ensure that there is no output sent before calling header() function, and make sure to call the header() function before any output is sent to the browser.

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

// Your PHP code here

ob_end_clean(); // Clean the output buffer without sending it
header("Location: new_page.php"); // Redirect to a new page
exit(); // Stop further execution
?>