Bird
0
0

Which PHP function call correctly moves the file pointer to the start of an opened file?

easy📝 Syntax Q3 of 15
PHP - File Handling
Which PHP function call correctly moves the file pointer to the start of an opened file?
Afseek($file, 0, SEEK_END);
Bfseek($file, 0, SEEK_SET);
Cfseek($file, 1, SEEK_CUR);
Dfseek($file, -1, SEEK_SET);
Step-by-Step Solution
Solution:
  1. Step 1: Understand fseek parameters

    fseek() takes three parameters: file handle, offset, and whence (position reference point).
  2. Step 2: Identify the correct whence for start

    SEEK_SET sets the pointer relative to the beginning of the file.
  3. Step 3: Set offset to zero

    Offset 0 with SEEK_SET moves pointer to the start.
  4. Final Answer:

    fseek($file, 0, SEEK_SET); -> Option B
  5. Quick Check:

    Offset 0 + SEEK_SET = start of file [OK]
Quick Trick: Use fseek with offset 0 and SEEK_SET to reset pointer [OK]
Common Mistakes:
  • Using SEEK_END instead of SEEK_SET
  • Using negative offset with SEEK_SET
  • Using SEEK_CUR with offset 0 expecting start

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes