What is the potential issue with including the DOCTYPE declaration in a PHP file before sending headers?

Including the DOCTYPE declaration before sending headers in a PHP file can cause an "Headers already sent" error because the DOCTYPE declaration is considered output. To solve this issue, you can ensure that the DOCTYPE declaration is included after sending headers by using output buffering in PHP.

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

// Send headers
header('Content-Type: text/html');

// Output DOCTYPE declaration
echo '<!DOCTYPE html>';

// Flush output buffer
ob_end_flush();