What is the EVA principle in PHP and how does it relate to the "Cannot modify header information" error?

The EVA principle in PHP stands for "Error, Validate, Action." It suggests that error handling should come first, followed by data validation, and then the actual action or processing. In the context of the "Cannot modify header information" error, this principle can be applied by checking if headers have already been sent before attempting to modify them.

if (!headers_sent()) {
    header('Location: new_page.php');
    exit();
} else {
    // Handle error or redirect in a different way
}