Web Designing MCQs

Top 20 MCQ Questions on Handling Files in PHP

Google+ Pinterest LinkedIn Tumblr
Here are the collections of top 20 MCQ questions on handling files in PHP includes multiple-choice questions on fundamentals of file handling in PHP. It includes MCQ questions on retrieving a path’s filename and directory, identifying the absolute path, calculating file, directory, and disk sizes, determining access and modification times, opening and closing files, reading file contents into a string variable and moving the file pointer in PHP.

Read Also: Top 20 MCQ Questions on Handling Strings in PHP

1) The pathinfo() function creates an associative array containing which of the following components of a path.
i. Directory Name
ii. Base Name
iii. File extension
A. i and ii only
B. ii and iii only
C. i and iii only
D. All i, ii and iii

2) The … function converts all symbolic links and relative path reference located in the path to their absolute counterparts.
A. realpath()
B. relativepath()
C. absolutepath()
D. path()

3) The … function returns a file’s last access time in UNIX timestamp format or FALSE on error.
A. unixtime()
B. fileatime()
C. filetime()
D. filectime()

4) The … function returns a file’s last changed time in UNIX timestamp format or FALSE on error.
A. unixtime()
B. fileatime()
C. filetime()
D. filectime()

5) The … function returns a file’s last modification time in UNIX timestamp format or FALSE otherwise.
A. unixtime()
B. fileatime()
C. filetime()
D. filectime()

6) Which of the following are the modes that are assigned at the time a resource is opened while reading and manipulation a file using the fopen() function.
i. r
ii. R
iii. a+
iv. X
A. i, ii and iii only
B. ii, iii and iv only
C. i, iii and iv only
D. All i, ii, iii and iv

7) State whether the following statements about opening a file with fopen() function are TRUE or FALSE.
i. The X mode will create and open the file for writing only.
ii. In the a+ mode, the file pointer is placed at the rare part of the file with the read and write feature enabled.
iii. In the X+ mode, if the file exists, fopen() will fail and an error of level E_WARNING will be generated.
A. i-True, ii-True, iii-False
B. i-False, ii-True, iii-True
C. i-True, ii-False, iii-True
D. i-False, ii-False, iii-True

8) The … function is capable of reading a file into an array, separating each element by the newline character.
A. file()
B. fgets()
C. fgetc()
D. readfile()

9) The … function reads the contents of a file into a string.
A. file()
B. fgets()
C. file_get_contents()
D. readfile()

10) The … function returns a certain number of characters read in through the opened resource handle or everything it has read up to the point when a new line or an EOF character is encountered.
A. file()
B. fgets()
C. file_get_contents()
D. readfile()

11) The … function returns a certain number of characters read in through the opened resource handle or everything it has read up to the point when a new line or an EOF character is encountered.
A. file_get_contents()
B. fgets()
C. fgetc()
D. readfile()

12) The … function reads an entire file specified by filename and immediately outputs it to the output buffer, returning the number of bytes read.
A. fscanf()
B. fgets()
C. fread()
D. readfile()

13) The … function offers a convenient means for parsing a resource in accordance with a predefined format.
A. fscanf()
B. fgets()
C. fread()
D. readfile()

14) The … function retrieves the current position of the file pointers offset within the resource.
A. fscanf()
B. ftell()
C. fseek()
D. rewind()

15) The … function returns an array consisting of files and directories found in the directory or returns FALSE on error.
A. fscanf()
B. scandir()
C. readdir()
D. rewind()

16) The … function sets the file filenames last modified and last accessed times, returning TRUE on success or FALSE on error.
A. fscanf()
B. ftell()
C. setf()
D. touch()

17) You can use the… function to list all files and child directories in a given directory.
A. fscanf()
B. scandir()
C. readdir()
D. rewind()

18) The … function moves the pointer to the location specified by a provided offset value.
A. fscanf()
B. ftell()
C. fseek()
D. rewind()

19) The … function returns the total size, in bytes, consumed by the disk partition housing a specified directory.
A. total_space()
B. disk_space()
C. disk_space_total()
D. disk_total_space()

20) The … function operates similarly to fgets(), except that if also strips any HTML and PHP tags from the input.
A. fgetss()
B. fgetsh()
C. fgetsp()
D. fgetst()

Answers

  1. D. All i, ii and iii
  2. A. realpath()
  3. B. fileatime()
  4. D. filectime()
  5. C. filetime()
  6. B. ii, iii and iv only
  7. C. i-True, ii-False, iii-True
  8. A. file()
  9. C. file_get_contents()
  10. B. fgets(0
  11. C. fgetc()
  12. D. readfile()
  13. A. fscanf()
  14. B. ftell()
  15. B. scandir()
  16. D. touch()
  17. C. readdir()
  18. C. fseek()
  19. D. disk_total_space()
  20. A. fgetss()

Shuseel Baral is a web programmer and the founder of InfoTechSite has over 8 years of experience in software development, internet, SEO, blogging and marketing digital products and services is passionate about exceeding your expectations.

Write A Comment