What potential issues can arise when using file_exists() in PHP scripts?

One potential issue when using file_exists() in PHP scripts is that it only checks if a file exists and does not differentiate between files and directories. To solve this, you can use is_file() to specifically check if a file exists.

// Check if a file exists
$file_path = 'example.txt';

if (file_exists($file_path) && is_file($file_path)) {
    echo "File exists!";
} else {
    echo "File does not exist!";
}