How can PHP's include function be utilized to check for errors in files before including them in the script?
When using the include function in PHP to include files in a script, it's important to check for errors in those files before including them to prevent any potential issues in the main script. One way to do this is by using the file_exists function to check if the file exists before including it. Additionally, you can use the is_readable function to check if the file is readable before including it.
$file = 'myfile.php';
if (file_exists($file) && is_readable($file)) {
include $file;
} else {
echo "Error: File does not exist or is not readable.";
}