Why do i see a 'cannot modify header information' warning in php?

This warning is displayed when you try to use the `header()` function after the output has been sent to the browser. Example:

echo 'Hello World';
header('Location: another_page.php');
Solution:

ob_start(); // Start output buffering at the top of your script
echo 'Hello World';
header('Location: another_page.php');
ob_end_flush(); // End output buffering at the end of your script
Using output buffering can help prevent this issue.

Beginner's Guide to PHP