What are common pitfalls when including templates in a PHP-based website?

One common pitfall when including templates in a PHP-based website is not properly sanitizing user input, which can lead to security vulnerabilities such as cross-site scripting (XSS) attacks. To solve this issue, always make sure to sanitize any user input before including it in your templates.

// Example of sanitizing user input before including it in a template
$user_input = $_GET['input'];
$sanitized_input = htmlspecialchars($user_input, ENT_QUOTES, 'UTF-8');
include('template.php');