menu

PHP File Handling


1. What is the mode used for opening a file in PHP for appending data?

a

r

w

x


2. 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()


3. What is the function used to read a specific number of bytes from a file in PHP?

fread()

fgetc()

fgets()

fgetss()


4. What is the function used to read data from a file in PHP?

fgets()

fwrite()

fopen()

fclose()


5. What is the function used to check if a file exists in PHP?

file_exists()

file_open()

file_close()

file_read()


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

r

w

a

x


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

fwrite()

fread()

fopen()

fclose()


8. 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");


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

w

r

a

x


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

filesize()

file_get_size()

file_size()

get_file_size()