What are the potential issues with including external webpages using PHP include function?

One potential issue with including external webpages using the PHP include function is the security risk of including malicious code from untrusted sources. To mitigate this risk, it is important to validate and sanitize the included URL before using it in the include function.

$url = filter_var($_GET['url'], FILTER_VALIDATE_URL);
if ($url !== false) {
    include($url);
} else {
    echo "Invalid URL";
}