How can whitespace or empty lines in included files cause header modification errors in PHP?

Whitespace or empty lines in included files can cause header modification errors in PHP because any output, including whitespace, before the header() function is called will prevent the headers from being modified. To solve this issue, ensure that there is no output, including whitespace or empty lines, before calling the header() function in PHP files.

<?php
ob_start(); // Start output buffering
include 'included_file.php'; // Include the file with caution for whitespace
ob_end_clean(); // Clean the output buffer without sending output
header('Location: new_page.php'); // Set the header after ensuring no output
exit; // Exit to prevent further execution
?>