What are the potential issues with using include() in PHP for reading a file?

One potential issue with using include() in PHP for reading a file is that it can execute any PHP code within the file, which may pose a security risk if the file is not trusted. To solve this issue, you can use the readfile() function instead, which simply reads the contents of a file and outputs it to the browser without executing any PHP code.

<?php
$file = 'example.txt';

if (file_exists($file)) {
    readfile($file);
} else {
    echo "File not found.";
}
?>