What potential issues can arise when using file_exists() to check for the existence of files with specific file extensions like PDFs?

When using file_exists() to check for the existence of files with specific file extensions like PDFs, one potential issue is that the function only checks for the existence of a file, not its specific file extension. To accurately check for PDF files, you should use pathinfo() to extract the file extension and then compare it to 'pdf'. This ensures that you are specifically checking for files with the correct extension.

$file_path = 'path/to/file.pdf';

if (file_exists($file_path) && pathinfo($file_path, PATHINFO_EXTENSION) == 'pdf') {
    echo 'PDF file exists.';
} else {
    echo 'PDF file does not exist.';
}