What are the potential security risks of including content from external servers in a PHP template?

Including content from external servers in a PHP template can pose security risks such as cross-site scripting (XSS) attacks, where malicious scripts from the external server can be executed on the client's browser. To mitigate this risk, you should sanitize and validate any external content before including it in your PHP template.

<?php
// Sanitize and validate external content before including in PHP template
$external_content = filter_var($external_content, FILTER_SANITIZE_STRING);
echo $external_content;
?>