How can the EVA (Input-Processing-Output) principle be applied to PHP code to avoid header modification errors?

When working with PHP code, it is important to follow the EVA (Input-Processing-Output) principle to avoid header modification errors. This means that all output should be generated after processing any input or performing any necessary calculations. To ensure this, you should avoid sending any headers before processing input or generating output in your PHP scripts.

<?php
// Process input
$input = $_POST['input'];

// Perform calculations or data processing
$processed_data = processData($input);

// Generate output
echo $processed_data;

// Function to process input data
function processData($input) {
    // Processing logic here
    return $processed_data;
}
?>