200-710 · Question #23
What does the __FILE__ constant contain?
The correct answer is B. The full path to the current script. __FILE__ holds the full absolute path to the currently executing script file (e.g., /var/www/html/app/index.php), not just its filename - which is why B is correct and A is wrong. C is incorrect because __FILE__ has nothing to do with HTTP requests; that's what…
Question
Options
- AThe filename of the current script.
- BThe full path to the current script.
- CThe URL of the request made.
- DThe path to the main script.
How the community answered
(21 responses)- A14% (3)
- B71% (15)
- C10% (2)
- D5% (1)
Explanation
__FILE__ holds the full absolute path to the currently executing script file (e.g., /var/www/html/app/index.php), not just its filename - which is why B is correct and A is wrong. C is incorrect because __FILE__ has nothing to do with HTTP requests; that's what $_SERVER['REQUEST_URI'] handles. D is a trap: __FILE__ always reflects the current file, even if included from another script - the "main script" would be __DIR__ . '/' . basename($_SERVER['SCRIPT_FILENAME']) or similar.
Memory tip: Think of __FILE__ like asking "where am I on disk right now?" - the answer is always a full address (path), not just your name (filename).
Topics
Community Discussion
No community discussion yet for this question.