What are the potential pitfalls of using file_exists() function in PHP when checking for file existence?
The potential pitfall of using file_exists() function in PHP when checking for file existence is that it can return true for directories as well. To accurately check if a file exists, it's better to use is_file() function instead.
$file_path = 'path/to/file.txt';
if (is_file($file_path)) {
echo 'File exists.';
} else {
echo 'File does not exist.';
}