What are some best practices for dynamically loading content in iframes using PHP?

When dynamically loading content in iframes using PHP, it is important to ensure that the content being loaded is secure and does not pose a security risk to your website. One way to achieve this is by sanitizing the input data before loading it into the iframe. This can help prevent cross-site scripting attacks and other vulnerabilities.

<?php
// Sanitize the input data
$iframe_content = filter_var($_GET['content'], FILTER_SANITIZE_URL);

// Output the iframe with the sanitized content
echo '<iframe src="' . $iframe_content . '"></iframe>';
?>