What is the common error message "Cannot modify header information" in PHP and how can it be resolved?

The common error message "Cannot modify header information" in PHP occurs when there is an attempt to modify header information, such as using functions like header() or setcookie(), after any output has been sent to the browser. To resolve this issue, you need to ensure that no output is sent to the browser before calling functions that modify headers.

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

// Your PHP code here

ob_end_flush(); // Flush output buffer and send output to browser
?>