What is the common cause of the "Cannot modify header information" error in PHP?

The "Cannot modify header information" error in PHP typically occurs when there is output sent to the browser before PHP attempts to modify header information using functions like header() or setcookie(). To solve this issue, make sure there is no whitespace or any other output before calling functions that modify headers.

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

// Your PHP code here

ob_end_flush(); // Flush output buffer