nerdexam
Zend

200-710 · Question #24

What can prevent PHP from being able to open a file on the hard drive (Choose 2)?

The correct answer is A. File system permissions. Note: The question asks to "Choose 2," so the correct answers are actually A and B - the provided answer key appears incomplete. File system permissions (A) is correct because PHP ultimately runs as an OS process (e.g., www-data or apache), and if that user lacks read/write…

I/O

Question

What can prevent PHP from being able to open a file on the hard drive (Choose 2)?

Options

  • AFile system permissions
  • BFile is outside open_basedir
  • CFile is inside the /tmp directory.
  • DPHP is running in CGI mode.

How the community answered

(53 responses)
  • A
    85% (45)
  • B
    4% (2)
  • C
    9% (5)
  • D
    2% (1)

Explanation

Note: The question asks to "Choose 2," so the correct answers are actually A and B - the provided answer key appears incomplete.

File system permissions (A) is correct because PHP ultimately runs as an OS process (e.g., www-data or apache), and if that user lacks read/write permission on the target file or its parent directory, the OS will refuse access regardless of what PHP attempts.

open_basedir restriction (B) is correct because open_basedir is a PHP configuration directive that jails file access to a specified directory tree. Any attempt to open a file outside that tree triggers a fatal error - PHP enforces this before even asking the OS.

The /tmp directory (C) is wrong because /tmp is typically more accessible, not less - PHP frequently uses it for session files and temp uploads. Being inside /tmp is no barrier.

CGI mode (D) is wrong because the execution mode (CGI vs. mod_php vs. FPM) affects how PHP receives requests, not how it accesses the filesystem. File access works the same way across all modes.

Memory tip: Think of two "gatekeepers" - the OS (permissions) and PHP itself (open_basedir). Either gatekeeper can independently block file access, so check both when fopen() fails unexpectedly.

Topics

#file permissions#open_basedir#file access restrictions#security directives

Community Discussion

No community discussion yet for this question.

Full 200-710 Practice