Bird
0
0

Which PHP function checks if a file or directory exists at a given path?

easy📝 Conceptual Q11 of 15
PHP - File Handling
Which PHP function checks if a file or directory exists at a given path?
Afilesize()
Bis_file()
Cfile_exists()
Dis_readable()
Step-by-Step Solution
Solution:
  1. Step 1: Understand the purpose of file_exists()

    The function file_exists() returns true if the file or directory exists at the specified path.
  2. Step 2: Compare with other functions

    Functions like is_file() check if the path is a file, filesize() returns size, and is_readable() checks permissions, but none check existence alone.
  3. Final Answer:

    file_exists() -> Option C
  4. Quick Check:

    Check existence = file_exists() [OK]
Quick Trick: Use file_exists() to check any file or directory presence [OK]
Common Mistakes:
  • Confusing is_file() with existence check
  • Using filesize() to check existence
  • Assuming is_readable() means file exists

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes