Complete the code to open a file for reading.
<?php $file = fopen('example.txt', '[1]'); ?>
The mode 'r' opens the file for reading only.
Complete the code to move the file pointer to the beginning of the file.
<?php
rewind([1]);
?>The variable holding the file resource is $file, so rewind($file) moves the pointer to the start.
Fix the error in the code to move the file pointer 10 bytes from the start.
<?php fseek([1], 10, SEEK_SET); ?>
The file resource variable is $file, so fseek($file, 10, SEEK_SET) correctly moves the pointer.
Fill both blanks to read 20 bytes from the file starting at byte 5.
<?php fseek([1], 5, SEEK_SET); $content = fread([2], 20); ?>
Both fseek and fread need the same file resource variable, which is $file.
Fill all three blanks to move the pointer 15 bytes from the end and read 10 bytes.
<?php fseek([1], [2], [3]); $data = fread([1], 10); ?>
Use fseek($file, -15, SEEK_END) to move 15 bytes before the end, then fread($file, 10) reads 10 bytes.