What are some common pitfalls when including PHP code in HTML files?

One common pitfall when including PHP code in HTML files is forgetting to properly escape characters, which can lead to syntax errors or security vulnerabilities. To prevent this, always use htmlspecialchars() function to escape any user input or dynamic content before outputting it in HTML.

<?php
// Example of properly escaping characters in PHP code included in HTML file
$user_input = "<script>alert('XSS attack');</script>";
echo htmlspecialchars($user_input);
?>