What are the potential pitfalls of using echo statements before sending headers in PHP?

Using echo statements before sending headers in PHP can result in the "Headers already sent" error, as headers must be sent before any output is sent to the browser. To avoid this issue, make sure to send headers before any output is generated, such as using echo statements.

<?php
// Correct way to set headers before output
header('Content-Type: text/html');

// Output content
echo "Hello, World!";
?>