PHP File Handling Quiz

Test your skills in PHP file handling by answering questions about reading, writing, opening, closing, and managing files effectively.

Last Updated :
Discuss
Comments

Question 1

Which PHP function is used to open a file?

  • fopen()

  • open()

  • file_open()

  • file()

Question 2

What function is used to close an open file handle?

  • close()

  • fclose()

  • file_close()

  • end()

Question 3

How can you check if a file exists before opening it?

  • file_check()

  • exists()

  • file_exists()

  • is_file()

Question 4

Which function deletes a file?

  • unlink()

  • delete()

  • remove_file()

  • file_delete()

Question 5

What is the typical file extension for CSV files?

  • .csv

  • .txt

  • .xls

  • .data

Question 6

How do you create a new directory in PHP?

  • mkdir()

  • makedir()

  • newdir()

  • create_folder()

Question 7

Which function lists files in a directory?

  • list_files()

  • scandir()

  • directory_list()

  • files_list()

Question 8

What function changes the permissions of a file?

  • chmod()

  • chperm()

  • fileperm()

  • setperm()

Question 9

How do you read a file line by line in PHP?

  • Using fgets() or fgetcsv() inside a loop

  • Using file_get_contents()

  • Using readfile()

  • Using readline()

Question 10

Which function returns the file extension of a file?

  • file_extension()

  • pathinfo()

  • ext()

  • get_extension()

Tags:

There are 10 questions to complete.

Take a part in the ongoing discussion