What is the potential risk of using eval() function in PHP to execute code from a text file?

Using the eval() function in PHP to execute code from a text file can pose a security risk as it allows for the execution of arbitrary code, making your application vulnerable to code injection attacks. To mitigate this risk, it is recommended to avoid using eval() and instead use alternative methods such as file_get_contents() to read the file contents and then execute it safely.

$fileContents = file_get_contents('path/to/your/file.txt');
eval('?>' . $fileContents);