menu

PHP File Handling


1. What is the function used to read a single character from a file in PHP?

fgetc()

fgets()

fread()

fgetss()


2. What is the function used to move the file pointer to a specified position in PHP?

fseek()

ftell()

rewind()

fsetpos()


3. What is the function used to read the entire contents of a file into a string in PHP?

file_get_contents()

file_put_contents()

fread()

fgets()


4. Which function is used to write data to a file in PHP?

fwrite()

fread()

fopen()

fclose()


5. What is the mode used for opening a file in PHP for reading only?

r

w

a

x


6. Which of the following is the correct way to write data to a file in PHP?

fwrite($file, "data");

fread("data", $file);

fwrite("data", $file);

fread($file, "data");


7. What is the mode used for opening a file in PHP for writing only?

w

r

a

x


8. What is the function used to get the size of a file in PHP?

filesize()

file_get_size()

file_size()

get_file_size()


9. What is the function used to get the current position of the file pointer in PHP?

ftell()

fseek()

rewind()

fgetpos()


10. What is the function used to close a file in PHP?

fclose()

fopen()

fwrite()

fread()