File System - Study Mode

[#6] What is the purpose of basename() function?
Correct Answer

(C) Strips of the path and returns the file name

[#7] What should you do if your script is having problem recognizing file endings from a text file saved on a platform different from the one you’re reading it on?
Correct Answer

(A) Change the auto_detect_line_endings INI setting

[#8] The ............ function checks if the "end-of-file" (EOF) has been reached.
Correct Answer

(D) feof()

[#9] The ........... function is used to read a single character from a file.
Correct Answer

(A) fgetc()

Explanation

Solution: Option A: fgetc() This function in PHP is used to read a single character from a file. It retrieves the next character from the file pointer and advances the file pointer position to the next character. Option B: fgets() The fgets() function is used to read a line from a file. It retrieves a line of text from the file pointer, including the newline character at the end of the line. Option C: fget() There is no fget() function in PHP related to file reading. This option is incorrect. Option D: fgetf() There is no fgetf() function in PHP related to file reading. This option is incorrect. Conclusion: The function used to read a single character from a file in PHP is fgetc() (Option A). This function is specifically designed to fetch individual characters from the file, making it the correct answer to the question.

[#10] The filesize() function returns the file size in ___________
Correct Answer

(B) bytes