Are there any potential security risks associated with using iframes in PHP to display external content?

Using iframes in PHP to display external content can pose security risks such as clickjacking, cross-site scripting (XSS), and phishing attacks. To mitigate these risks, it is important to ensure that the external content being displayed is from a trusted source and to sanitize any user input before displaying it in the iframe.

<?php
// Sanitize user input before displaying in iframe
$external_url = filter_var($_GET['url'], FILTER_VALIDATE_URL);

if ($external_url) {
    echo '<iframe src="' . $external_url . '"></iframe>';
} else {
    echo 'Invalid URL';
}
?>