Bird
0
0

What will the following PHP code output if the file 'test.txt' exists and is 200 bytes in size?

medium📝 Predict Output Q4 of 15
PHP - File Handling
What will the following PHP code output if the file 'test.txt' exists and is 200 bytes in size?
$size = filesize('test.txt');
echo $size;
A200
Btest.txt
Ctrue
DError: undefined function
Step-by-Step Solution
Solution:
  1. Step 1: Understand filesize() function

    filesize() returns the size of the file in bytes as an integer.
  2. Step 2: Analyze the echo statement

    echo $size; prints the integer value returned by filesize(), which is 200.
  3. Final Answer:

    200 -> Option A
  4. Quick Check:

    filesize() output = file size in bytes [OK]
Quick Trick: filesize() returns file size in bytes as integer [OK]
Common Mistakes:
  • Expecting filename instead of size
  • Thinking it returns boolean
  • Assuming function is undefined

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes