What are some best practices for embedding external content using iframes in PHP?

When embedding external content using iframes in PHP, it is important to sanitize the URL to prevent XSS attacks and ensure that the content being embedded is secure. One way to achieve this is by using the `filter_var()` function to validate and sanitize the URL before embedding it in an iframe.

<?php

// Sanitize the URL before embedding it in an iframe
$externalUrl = filter_var($externalUrl, FILTER_SANITIZE_URL);

// Embed the external content using an iframe
echo '<iframe src="' . $externalUrl . '" width="100%" height="500"></iframe>';

?>