What are the potential security risks of including files from a remote URL in PHP scripts?

Including files from a remote URL in PHP scripts can pose security risks such as remote code execution, exposing sensitive data, and potential malware injection. To mitigate these risks, it is recommended to avoid including files from remote URLs and instead download the file locally and include it from your server.

<?php

// Download the remote file locally
$remoteFile = file_get_contents('http://example.com/remote-file.php');
file_put_contents('local-file.php', $remoteFile);

// Include the locally downloaded file
include 'local-file.php';

?>