File System(Php ) Questions and Answers

Question 1. The filesize() function returns the file size in ___________
  1.    bits
  2.    bytes
  3.    kilobytes
  4.    gigabytes
Explanation:-
Answer: Option B. -> bytes

Question 2. Which one of the following function is capable of reading a specific number of characters form a file?
  1.    fgets()
  2.    fget()
  3.    fileget()
  4.    filegets()
Explanation:-
Answer: Option A. -> fgets()
Its prototype is string fgets(resource handle [, int length]). If the optional length parameter is omitted, 1024 character is assumed.

Question 3. Which one of the following function is capable of reading a file into an array?
  1.    file()
  2.    arrfile()
  3.    arr_file()
  4.    file_arr()
Explanation:-
Answer: Option A. -> file()

Question 4. Which one of the following PHP function is used to determine a file’s last access time?
  1.    fileltime()
  2.    filectime()
  3.    fileatime()
  4.    filetime()
Explanation:-
Answer: Option C. -> fileatime()
The fileatime() function returns a file’s last access time in Unix timestamp format or FALSE on error.

Question 5. Which one of the following function is capable of reading a file into a string variable?
  1.    file_contents()
  2.    file_get_contents()
  3.    file_content()
  4.    file_get_content()
Explanation:-
Answer: Option B. -> file_get_contents()

Question 6. Which one of the following function operates similarly to fgets(), except that it also strips any HTML and PHP tags form the input?
  1.    fgetsh()
  2.    fgetsp()
  3.    fgetsa()
  4.    fgetss()
Explanation:-
Answer: Option D. -> fgetss()

Question 7. Which one of the following function outputs the contents of a string variable to the specified resource?
  1.    filewrite()
  2.    fwrite()
  3.    filewrites()
  4.    fwrites()
Explanation:-
Answer: Option B. -> fwrite()

Question 8. Which one of the following function reads a directory into an Array?
  1.    scandir()
  2.    readdir()
  3.    scandirectory()
  4.    readdirectory()
Explanation:-
Answer: Option A. -> scandir()
It returns an array consisting of files and directories found in directory or returns FALSE on error.

Question 9. Which function sets the file filename’s last-modified and last-accessed times?
  1.    sets()
  2.    set()
  3.    touch()
  4.    touched()
Explanation:-
Answer: Option C. -> touch()
Its prototype is int touch(string filename [, int time [, int atime]]). It returns TRUE on success or FALSE on error.

Question 10. Which function is useful when you want to output the executed command’s result?
  1.    out_cmm()
  2.    out_system()
  3.    cmm()
  4.    system()
Explanation:-
Answer: Option D. -> system()