menu

PHP File Handling


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

filesize()

file_get_size()

file_size()

get_file_size()


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

ftell()

fseek()

rewind()

fgetpos()


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

file_exists()

file_open()

file_close()

file_read()


4. What is the function used to delete a file in PHP?

unlink()

delete()

remove()

erase()


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

fgetc()

fgets()

fread()

fgetss()


6. Which of the following is the correct way to open a file in PHP in binary mode?

fopen("file.bin", "rb");

fopen("file.bin", "r");

fopen("file.bin", "w");

fopen("file.bin", "a");


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

a

r

w

x


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

r

w

a

x


9. What is the function used to write a string to a file in PHP?

file_put_contents()

file_get_contents()

fwrite()

fgets()


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

fwrite()

fread()

fopen()

fclose()