What are the potential issues with including scripts from external servers in PHP pages?

Including scripts from external servers in PHP pages can pose security risks such as cross-site scripting (XSS) attacks or data leaks. To mitigate these risks, it is important to validate and sanitize any user input before including external scripts. Additionally, consider using Content Security Policy (CSP) headers to restrict which external sources can be loaded on your page.

<?php
header("Content-Security-Policy: script-src 'self' https://example.com");
?>